Wednesday, December 18, 2013

JSP Dropdown Example



 The following example displays:
(1)a default option: ---Select--- , means empty input.
(2) options to choose from. Option values are obtained from a list ${technologyList}. JSTL is used to retrieve and pass the values to <form:option> tag.

                         <span class="sp-fieldlabel">Sub-Type</span>

                        <form:select path="searchCriteria.subType" cssClass="sp-select">
                            <option value="-1">
                                      --<spring:message code="generic.dropdown.selection" />--
                            </option>

                            <c:forEach items="${SiteSubTypes}" var="element">
                                <form:option value="${element}">${element}</form:option>
                            </c:forEach>
                        </form:select>

In the above code example,   <spring:messagecode="generic.dropdown.selection"/>  uses Spring's localization feature. Below shows the results of the above JSP:

No comments:

Post a Comment