[prev in list] [next in list] [prev in thread] [next in thread] 

List:       struts-user
Subject:    Fw: <logic:iterate> how to test the 1st and last iteration ?
From:       "Martin Gainty" <mgainty () hotmail ! com>
Date:       2007-04-28 2:02:39
Message-ID: BAY133-DAV1365F32950A10934E3A78CAE4E0 () phx ! gbl
[Download RAW message or body]

Tim 
for 2.x use the 
ww:iterator 
  ww:if test="#foo=bar"
http://struts.apache.org/2.x/docs/iteration-tags.html

M--
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.

----- Original Message ----- 
From: "Tim B" <timblanchard@shaw.ca>
To: <user@struts.apache.org>
Sent: Friday, April 27, 2007 9:09 PM
Subject: Re: <logic:iterate> how to test the 1st and last iteration ?


> 
> "piloupy GOTTAPIL" <b7ixbn0873hnb0x2@yopmail.com> wrote in message
> news:1fc9ddf30704270542m3aae605dq742a645460710939@mail.gmail.com...
>> Hi,
>>
>> What I want to do is quite simple. I'd like to know how to test in a
>> <logic:iterate> when I'm at the first or last iteration.
>>
>> My present problem is to parse a collection of String and display the
>> results like this :
>>
>> ### CODE : begin ###
>> value1, value2, value3
>> ### CODE : end ###
>>
>> And as you can see, for the last iteration, I mustn't displey the
>> comma character.
>>
>> My present code is :
>>
>> ### CODE : begin ###
>> <logic:iterate id="e" name="myCollection">
>>   <bean:write name="e" property="name" />,
>> </logic:iterate>
>> ### CODE : end ###
>>
>> Thanks in advance :)
>>
>> piloupy
> 
> 
> how about using the length and offset attributes like so:
> 
> <!--display first item of list with no comma-->
> <logic:iterate id="e" name="myCollection" length="1">
>  <bean:write name="e" property="name" />
> </logic:iterate>
> 
> <!--display remaining items of list with a  comma and space prepended to
> each-- >
> <logic:iterate id="e" name="myCollection" offset="1">
>  , <bean:write name="e" property="name" />
> </logic:iterate>
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic