assuming the Struts form bean is called 'formbean' and the property is called 'property'
<select size="1" name="property" multiple="false"> <c:forEach items='${NameOfTheCollectionOfJavaBeans}' var='item'> <option value="<c:out value='${item.value}'>" <c:if test="${item.value==formbean.property}">selected</c:if>><c:out value='${item.label}'></option> </c:forEach> </select>
or in JSP2.0:
<select size="1" name="property" multiple="false"> <c:forEach items="${NameOfTheCollectionOfJavaBeans}" var="item"> <option value="${item.value}" ${item.value==formbean.property ? "selected" : }>${item.label}</option> </c:forEach> </select>
Caroline Jen wrote:
To make it simple, there is a JavaBean. This JavaBean has two properties: label and value. Because I have a number of label and value pairs, I have a Collection of this JavaBean(s).
To create a drop down menu, I do the following:
<bean:define id="GiveAnyName" name="NameOfTheCollectionOfJavaBeans" scope="request" type="java.util.ArrayList" />
<html:select size="1" property="Property in the form bean to hold the selection" multiple="false"> <html:options collection="NameOfTheCollectionOfJavaBeans" property="value" labelProperty="label"/> </html:select>
How do I use the <c:... > tag to do the same thing?
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- Jason Lea
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]