I have this in a jsp
:
<% include file="../../common.jsp %>
<!-- engine size -->
<c:set var="maxLength" value="4" />
<c:set var="cssClass" value="input-text small vehicle vehicleCc vehicleSearch modelSearch" />
<c:set var="path" value="vehicle.cc" />
<c:set var="label" value="vehicle.cc" />
<c:set var="explanation" value="vehicle.cc.electric" />
<c:set var="help" value="whatsthis.cc" />
<c:set var="helpLink" value="car.cc.link" />
<%@ include file="../../common/fieldrows/textbox.jsp %>
...
The property vehicle.cc.electric
has value if electric, enter 0
When I run my application and access the engine size area through the borwser, the correct message is displayed but it appears as a hyperlink but when clicked it does not take you anywhere.
Further down the same file I have the following:
...
<!-- list cars -->
<c:set var="cssClass" value="largest carList" />
<c:set var="path" value="carList" />
<c:set var="label" value="vehicle.select" />
<c:set var="explanation" />
<spring:message code="label.matching.vehicles" />
</c:set>
<%@ include file="../../common/fieldrows/listbox.jsp" %>
If I add <c:set var="explanation" value="vehicle.cc.electric" />
below <c:set var="label" value="vehicle.select" />
it appears as I wish, without looking like a hyperlink. How is this done?
Additional info
I noticed that textbox.jsp
contains the following:
<div class="additional-info" id="informaion">
<spring:message code="${explanation}" />
</div>
listbox.jsp
is slightly different in that it does not contain the id
field:
<div class="additional-info">
<spring:message code="${explanation}" />
</div>
When I removed id
from textbox.jsp
I got <c:set var="explanation" value="vehicle.cc.electric" />
to display as desired. I'm not sure what the purpose of id
is though. I'm completely new to jsp
so any info/help would be appreciated.
CodePudding user response:
Options to resolve this were:
- Create a new variable. E.g
electric
. Then have<c:set var="electric" value="vehicle.cc.electric" />
and add this to textbox.jsp:
<c:if test="${!empty electric}">
<div class="additional-info">
<spring:message code="${electric}" />
</div>
</c:if>
Provide an override for the id
Create a copy of textbox.jsp and just use what you need.
I went for option 1.