</logic:notPresent>
</logic:notPresent>
</logic:equal>
This code, which follows the check for drop-down box field, defines how to display the content of
the drop-down box field, if present. Displaying the content of the drop down box requires
denoting which of the available options is selected. If no option is selected, displays the default
value as the selected option:
<%-- ========== --%>
<%-- select box --%>
<%-- ========== --%>
<logic:equal name="customField" property="type"
value="<%=Integer.toString(CustomFieldConst.TYPE_DROP_DOWN)%>">
<select name="<%=cfName%>" id="<%=customField.getName()%>">
<%-- iterate over the options --%>
<logic:iterate id="optionValue" name="customField"
property="optionValues"
type="java.lang.String">
<%
//-- if the entry has a value, make it selected. --//
if ( null != customField.getVal() ) {
if ( optionValue.equals(customField.getVal()) ) {
%>
<option value="<%=optionValue%>"
selected><%=optionValue%></option>
<%
} else {
%>
<option value="<%=optionValue%>"><%=optionValue%></option>
<%
}
//-- the entry has no default, make the default option selected.
--//
} else {
if ( optionValue.equals(customField.getDefaultValue()) ) {
%>
<option value="<%=optionValue%>"
selected><%=optionValue%></option>
<%
} else {
Chapter 5: Customizing JavaServer Pages 43