This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting indexId from logic:iterate tag

 
John Smith
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is my sample code from action class. The choices object might vary from ResultSet. I am using two items for testing iterate tag in JSP page.
-----------------------------------------------------------------
Collection choices = new ArrayList();
choices.add(new AMSLabelValueBean("Letter", "CL1", "CL2", "CL3"));
choices.add(new AMSLabelValueBean("Card", "CI1", "CI2", "CI3"));
request.setAttribute("choices", choices);


AMSLabelValueBean is just getter and setter method for "intrusiveIndicator" fields.
---------------------------------------------------------------------
here is struts-config.xml
<form-beans>
<form-bean name="radioForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="control" type="java.lang.String"/>
</form-bean>
</form-beans>
---------------------------------------------------------------------
Here is JSP
<logic:iterate id="choice" name="choices" indexId="idx">
<tr>
<td><bean:write name="choice" property="label"/></td>
<td><html:radio property="control" idName="choice<%=idx.intValue()%>" value="intrusiveIndicator"/></td>
</tr>
</logic:iterate>

I am trying to get incremental names for radio buttons, but it says "No getter method available for property control<%=idx.intValue()%> for bean under name org.apache.struts.taglib.html.BEAN". I am not sure that I am providing enouch code. but it would be very helpful if someone can answer. I am just trying to generate dynamic radio buttons depending on result set coming from a database.

Thanks.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Change the idName attribute in the tag to idName="choice" and it will work if AMSLabelValueBean has a property of "intrusiveIndicator" and a getIntrusinveIndicator() method.

Here's the explanation in the user guide:


If an iterator is used to render a series of radio tags, the idName attribute may be used to specify the name of the bean exposed by the iterator. In this case, the value attribute is used as the name of a property on the idName bean that returns the value of the radio tag in this iteration.

[ March 17, 2005: Message edited by: Merrill Higginson ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic