You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by samsun <gr...@barcap.com> on 2009/09/24 18:28:44 UTC

iterator tag: how to set iterate step?

I have array to iterate through using iterator tag, for each loop i want to
print out pair of array's element
the last row could have only one element if the array length is odd. for
example, i want to dump arrays into table , each row has two element.

arrays {1,2,3,4,5} 

<tr>
  <td>1</td>   <td>2</td>
</tr>
 
<tr>
 <td>3</td>   <td>4</td>
</tr>

<tr>
 <td>5</td> 
</tr>


each loop's step should set to 2, but looks like there is no step attribute
for the iterator tag.
any idea how to do this

thanks,

-- 
View this message in context: http://www.nabble.com/iterator-tag%3A-how-to-set-iterate-step--tp25577792p25577792.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: iterator tag: how to set iterate step?

Posted by Dale Newfield <da...@newfield.org>.
Tommy Pham wrote:
>>> arrays {1,2,3,4,5}
>>>
>>>  1   2
>>>  3   4
>>>  5

> What about
> <tr>
>   <s:iterator status="stat" value="{1,2,3,4,5}" >
>     <td><s:property value="#stat.index" /></td>
>     <s:if test="%{#stat.index %2 == 0}">
>       </tr><tr>
>     </s:if>
>   </s:iterator>
> </tr>

That s:if should also make sure you're not on the last iteration, 
otherwise you'll end up with an empty row.

-Dale

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


Re: iterator tag: how to set iterate step?

Posted by Tommy Pham <to...@yahoo.com>.



----- Original Message ----
> From: Musachy Barroso <mu...@gmail.com>
> To: Struts Users Mailing List <us...@struts.apache.org>
> Sent: Thursday, September 24, 2009 10:19:55 AM
> Subject: Re: iterator tag: how to set iterate step?
> 
> no way i know of in 2.1.6. There will be one in the next release
> 
> musachy
> 
> On Thu, Sep 24, 2009 at 9:28 AM, samsun wrote:
> >
> > I have array to iterate through using iterator tag, for each loop i want to
> > print out pair of array's element
> > the last row could have only one element if the array length is odd. for
> > example, i want to dump arrays into table , each row has two element.
> >
> > arrays {1,2,3,4,5}
> >
> > 
> >  1   2
> > 
> >
> > 
> >  3   4
> > 
> >
> > 
> >  5
> > 
> >
> >
> > each loop's step should set to 2, but looks like there is no step attribute
> > for the iterator tag.
> > any idea how to do this
> >
> > thanks,
> >
> > --
> > View this message in context: 
> http://www.nabble.com/iterator-tag%3A-how-to-set-iterate-step--tp25577792p25577792.html
> > Sent from the Struts - User mailing list archive at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> 
> 
> 
> -- 
> "Hey you! Would you help me to carry the stone?" Pink Floyd
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org

What about
<tr>

<s:iterator status="stat" value="{1,2,3,4,5}" >
<td><s:property value="#stat.index" /></td>
    <s:if test="%{#stat.index %2 == 0}">
    </tr><tr>
</s:if>
</s:iterator></tr>


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


Re: iterator tag: how to set iterate step?

Posted by Musachy Barroso <mu...@gmail.com>.
no way i know of in 2.1.6. There will be one in the next release

musachy

On Thu, Sep 24, 2009 at 9:28 AM, samsun <gr...@barcap.com> wrote:
>
> I have array to iterate through using iterator tag, for each loop i want to
> print out pair of array's element
> the last row could have only one element if the array length is odd. for
> example, i want to dump arrays into table , each row has two element.
>
> arrays {1,2,3,4,5}
>
> <tr>
>  <td>1</td>   <td>2</td>
> </tr>
>
> <tr>
>  <td>3</td>   <td>4</td>
> </tr>
>
> <tr>
>  <td>5</td>
> </tr>
>
>
> each loop's step should set to 2, but looks like there is no step attribute
> for the iterator tag.
> any idea how to do this
>
> thanks,
>
> --
> View this message in context: http://www.nabble.com/iterator-tag%3A-how-to-set-iterate-step--tp25577792p25577792.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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