struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Kiley <jhki...@summa-tech.com>
Subject Re: why doesnt iterator tag provide 'next'
Date Sun, 31 May 2009 14:02:56 GMT
Assuming that you're iterating over a List, why not instead iterate over a
List of Integers, and use those Integers as the index to your iterator?  You
can increment the counter inside the iterator.  Or if you need to get foo[0]
and foo[1] on the first run through, foo[2] and foo[3] on the next run, you
could iterate over a List {0, 2, 4, 6, 8...} and get dataList[i] and
dataList [i + 1].  It's easy enough to dynamically generate the List of
Integers in your action class.
jk

On Sun, May 31, 2009 at 9:58 AM, Bhaarat Sharma <bhaarat.s@gmail.com> wrote:

> sadly in my case i need to :(
>
> But this takes us back, the pseudocode you are suggesting is not possible
> using s:iterate, I dont think we have the ability to move the cursor (or
> current value in top stack) withtin the iterator tag.  Neither does jstl
> provide this.  So sadly, will my code have to sit back in time and use
> scriptlets.
>
> On Sun, May 31, 2009 at 9:49 AM, Dave Newton <newton.dave@yahoo.com>
> wrote:
>
> > Bhaarat Sharma wrote:
> >
> >> how would 'if' help with 'next'.  can you please give an example?
> >>
> >
> > Pseudocode Java; this is something people should be able to figure out
> for
> > themselves. In JSP I might just use the index.
> >
> > for (Foo curr : foos) {
> >    if (alt) {
> >        ...
> >    } else prev = curr;
> >    alt = !alt;
> > }
> >
> > OTOH, I'd probably never *need* to do this.
> >
> >
> > Dave
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>



-- 
Jim Kiley
Senior Technical Consultant | Summa
[p] 412.258.3346
http://www.summa-tech.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message