Return-Path: Delivered-To: apmail-struts-user-archive@www.apache.org Received: (qmail 58190 invoked from network); 31 May 2009 14:03:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 31 May 2009 14:03:41 -0000 Received: (qmail 51262 invoked by uid 500); 31 May 2009 14:03:51 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 51210 invoked by uid 500); 31 May 2009 14:03:51 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 51200 invoked by uid 99); 31 May 2009 14:03:50 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 31 May 2009 14:03:50 +0000 X-ASF-Spam-Status: No, hits=3.4 required=10.0 tests=HTML_MESSAGE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.85.132.249] (HELO an-out-0708.google.com) (209.85.132.249) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 31 May 2009 14:03:40 +0000 Received: by an-out-0708.google.com with SMTP id d14so3611493and.17 for ; Sun, 31 May 2009 07:03:17 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.249.14 with SMTP id w14mr3377007anh.162.1243778597050; Sun, 31 May 2009 07:03:17 -0700 (PDT) In-Reply-To: <491bd2b50905310658w2d95e9c2v8c591e5fd26c09f6@mail.gmail.com> References: <491bd2b50905292034i4d335521qc271e69a75a6711f@mail.gmail.com> <491bd2b50905300551q655bbdban5d808aa3a6e594e9@mail.gmail.com> <491bd2b50905301710v549b78ecx12f5d4515833d482@mail.gmail.com> <491bd2b50905310633m1d8cf0balfb6e748421ff1462@mail.gmail.com> <4A228AD9.1050506@yahoo.com> <491bd2b50905310658w2d95e9c2v8c591e5fd26c09f6@mail.gmail.com> From: Jim Kiley Date: Sun, 31 May 2009 10:02:56 -0400 Message-ID: <366601530905310702x6040eda0gd778de0faf1b7096@mail.gmail.com> Subject: Re: why doesnt iterator tag provide 'next' To: Struts Users Mailing List Content-Type: multipart/alternative; boundary=0016368e1d5d74d90d046b35c5c1 X-Virus-Checked: Checked by ClamAV on apache.org --0016368e1d5d74d90d046b35c5c1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 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 > 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 --0016368e1d5d74d90d046b35c5c1--