Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using logic:iterate in select box

 
ramji srinivasan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

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>
</logic:iterate>
</html:select>

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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to use expression language as following :

 
Periakaruppan Thiagarajan
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
</html:select>

Where
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
Posts: 258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic