jQuery in Action, 3rd edition
The moose likes Struts and the fly likes Using logic:iterate in select box Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Using logic:iterate in select box" Watch "Using logic:iterate in select box" New topic

Using logic:iterate in select box

ramji srinivasan

Joined: Aug 22, 2005
Posts: 11

i have a multiselect box and i want to set the values and the options using <logic:iterate>...the following is my code

<html:select name="ReqBean" multiple="true" property="scopeAllChoices">
<logic:iterate id="Req" name="ReqBean" property="arrScope">
<html ption value="<bean:write name='Req'Property='scopeID'/>">
<bean:write name="Req" property="scopeDesc"/>
</html ption>

here ReqBean is the form bean and arrScope is the arraylist containing two items namely scopeID and scopeDesc...
when i run this code i get the value as <bean:write..> tag itself...please suggest me a solution.
Cendy Nguvy
Ranch Hand

Joined: May 25, 2005
Posts: 37
Try to use expression language as following :

Periakaruppan Thiagarajan
Ranch Hand

Joined: Jul 26, 2005
Posts: 65
This code might solve your problem.

<html:select property="scopeAllChoices" name="ReqBean" multiple="true">
<logic resent name="ReqBean" property = "eligGrpMemIdList">
<html ption value="-1" >
<bean:message key="txtAll"/></html ption>
<html ptions name="ReqBean" property = "scopeID" labelName="ReqBean" labelProperty = "scopeDesc"></html ptions>
</logic resent>

scopeAllChoices must be a String[] which holds the selected list of values.
scopeID must be an arraylist containing id's
scopeDesc must be an arraylist containing desc
Pranav Sharma
Ranch Hand

Joined: Oct 27, 2003
Posts: 258
This would be a nice way to do it if you want to make it truly dynamic.

In your action

In jsp:

But i think the previous reply may work
I agree. Here's the link: http://aspose.com/file-tools
subject: Using logic:iterate in select box
jQuery in Action, 3rd edition