You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kalyan Ayyagari <ka...@revenuetech.com> on 2005/05/25 14:22:07 UTC
how to get the index of the outer loop
I have a nested loop using nested:iterate. Inside the inner loop I have a
radio button. I want to group the radio buttons based on the index of the
outer loop. How can I do it?
Here's the code snapshot:
<nested:iterate property="outerProp" > OuterProperty:
<nested:iterate id="row" property="innerProp"
type="java.my.someType"> InnerProperty:
<nested:radio name="row" property="selectedId"
value="myId" indexed="true" /> My Radio Property
</nested:iterate>
<nested:iterate>
With the indexed="true", my radio buttons are being rendered, for example,
like this:
OuterPropety0:
InnerProperty0: row[0].selectedId
InnerProperty1: row[1].selectedId
InnerProperty2: row[2].selectedId
OuterPropety1:
InnerProperty0: row[0].selectedId
InnerProperty1: row[1].selectedId
InnerProperty2: row[2].selectedId
Whereas, I want it to be like this:
OuterPropety0:
InnerProperty0: row[0].selectedId
InnerProperty1: row[0].selectedId
InnerProperty2: row[0].selectedId
OuterPropety1:
InnerProperty0: row[1].selectedId
InnerProperty1: row[1].selectedId
InnerProperty2: row[1].selectedId
Thanks,
Kalyan
Re: how to get the index of the outer loop
Posted by Wendy Smoak <ja...@wendysmoak.com>.
From: "Kalyan Ayyagari" <ka...@revenuetech.com>
> I have a nested loop using nested:iterate. Inside the inner loop I have a
> radio button. I want to group the radio buttons based on the index of the
> outer loop. How can I do it?
http://struts.apache.org/userGuide/struts-logic.html#iterate
You can expose the current index by using the 'indexId' attribute, but I'm
not sure how to use that index in the 'classic' tags without expressions. I
would do this with JSTL and <c:forEach> using the varStatus attribute.
--
Wendy Smoak
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org