File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 256
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:
subject: Using logic:iterate in select box
Similar Threads
using c:out in a href and html:select
How to use html:options
html:option woes
set html:option to defalut bean value
Dynamically displaying html:option values