I think you're making this more difficult than it needs to be. You want to
use a Select to set a property in your ActioForm, so in the ActionForm you
have something like this...
protected String productId;
protected List products;
public void setProductId(String productId) {
this.productId = productId;
}
public String getProductId() {
return productId;
}
public List getProducts() {
return products;
}
The List of products contains "Product" beans with "id" and "name"
properties and the appropriate getters/setters.
Then in your jsp...
<html:select name="myProductForm" property="productId">
<html:optionsCollection name="myProductForm" property="products"
label="name" value="id"/>
</html:select>
The <html:optionsCollection> will retrieve the Collection using the
name/property attributes and iterate through it rendering options for each
bean using the label/value attributes. If any of the "ids" match the value
retrieved by the <Select> tag using its name/property then it will set that
option to "selected".
HTH
Niall
----- Original Message -----
From: "PADALA, SANDHYA (SBCSI)" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Thursday, May 20, 2004 7:22 PM
Subject: <html:option> and <c:out> tags
Hello ,
I have a question on how to use <C:out> tag as the value to the
value attribute of <html:option> tag
On my JSP
<html:select property="optionList">
<c:forEach items="${TaskForm.optionList}" var="optionList">
<html:option value="<c:out value=${optionList.optionID}/>"><c:out
value="${optionList.optionName}"/></html:option>
</c:forEach>
</html:select>
When I run this JSp and do a view source
I get the following code
<select name="actionList"><option value="<c:out
value=${optionList.optionID}/>">abc</option>
<option value="<c:out value=${optionList.optionID}/>">xyz</option>
<option value="<c:out
value=${optionList.optionID}/>">pqr</option></select>
Can anyone of you tell me how can I get the c:out get evaluated and the
value to be stored in the value attribute of option tag.
Thanks in advance.
Sandhya
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]