I am also interested in this. The IterateTag uses "lengthCount" to keep
track of the current iteration, however this is a protected variable and
there is no getter to expose it.

Would it be possible to put in a public getLengthCount() in the IterateTag?
This wouldn't solve Chris's problem directly but then other tags embedded in
the IterateTag could then use:
         findAncestorWithClass(this, IterateTag.class)
to get hold of it and then call getLengthCount().

I have two different scenarios where I needed to do this and I've
sub-classed IterateTag to achieve it. However it would be really useful if
it was in the original version.

I have a <html:row oddColor=".." evenColor=".."> tag which generates rows
with alternating colors which  needs this and from various posts I've seen
might be useful to quite a few people. It generates <tr
bgcolor="..">....</tr> elements.

Niall

> -----Original Message-----
> From: Chris Butler [mailto:[EMAIL PROTECTED]]
> Sent: 23 April 2001 16:53
> To: [EMAIL PROTECTED]
> Subject: iteration enhancement?
>
>
> Is it possible to access the count of the number of
> times you've looped in an <iterate> tag?
>
> ideally:
>
> <logic:iterate id="rowX" name="rows">
>    #<bean:write name="rowX" property="count"/>
>     <bean:write name="rowX" property="someProperty"/>
> </logic:iterate>
>
> unfortunately, i'm guessing that via reflection the
> bean is created with a reference name and additional
> attributes aren't there...
>
> chris
>
>

Reply via email to