Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

dynamic dropdown list with JSTL

843840Oct 3 2008 — edited Oct 3 2008
I have an object that has a few different string and string array properties. I want to build a cascading dropdown list from these (I'm using the Springs SimpleFormController to fill these in the referenceData() method)

SearchFieldName object
	public class SearchFieldName {
	private String name;
	private String display;
	private String type;
	private String[] operators;
	private String[] values;
	private String[] displayValues;
	public ArrayList<SearchFieldName> searchFieldList;
SimpleFormController
	//searchFieldList is a collection of SearchFieldName's
 	//selectedFieldName is one particular instance of SearchFieldName.getName() 
	Map<String, Object> refData = new HashMap<String, Object>();
		refData.put("searchFields", searchFieldList);
		refData.put("selectedFieldName", selectedFieldName);
the jsp:
<c:set var="count" value="-1" />
<c:forEach var="selectedField" items="${selectedFieldName}">
	<c:set var="count" value="${count + 1}"></c:set>

	<!-- Field types -->
    <select name="fields_${count}" id="additional_search_field_${count}">
		<c:forEach var="fieldItem" items="${searchFields}">
			<c:choose>
				<c:when test="${selectedField == fieldItem.name}">
					<option value="${fieldItem.name}" selected="selected">${fieldItem.display}</option>
				</c:when>
				<c:otherwise>
					<option value="${fieldItem.name}">${fieldItem.display}</option>
				</c:otherwise>
			</c:choose>	    	
	    </c:forEach>
    </select>

	<!-- Operators -->
	<c:forEach var="fieldItem" items="${searchFields}">
		<c:choose>
			<c:when test= ??? fields_${count}.selected = fieldItem ??? >
			    <select name="operators_${count}" id="additional_search_operator_${count}">
					<c:forEach var="operator" items="${fieldItem.operators}">
						<option value="${operator}">${operator}</option>
				    </c:forEach>
			    </select>
			</c:when>
			<c:otherwise>
				&nbsp;
			</c:otherwise>
		</c:choose>	
	</c:forEach>

</c:forEach>
the problem is currently with the line
<c:when test= ??? fields_${count}.selected = fieldItem ??? >

I don't know how to set up the syntax for that if - this is where i could benefit from some client side process to handle the cascading part

(I'll be honest, I didn't do a thurough search for this problem yet - I'll do that now just to be sure)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 31 2008
Added on Oct 3 2008
1 comment
2,519 views