You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ganesh <em...@yahoo.co.in> on 2010/04/20 11:21:54 UTC
Counter question
Hello all,
I have a integer value and i have to show that many number of images. Could any one help me how to use the Counter tag.
Regards
Ganesh
Send instant messages to your online friends http://in.messenger.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Counter question
Posted by Dale Newfield <da...@newfield.org>.
On 4/20/10 5:21 AM, Ganesh wrote:
> I have a integer value and i have to show that many number of images.
> Could any one help me how to use the Counter tag.
More recent struts2 versions have more useful iterator use cases, so now
you can just use begin, end, and step
http://struts.apache.org/2.x/docs/iterator.html
If you're using 2.0 for some reason you can use an OGNL trick to get the
result you're after:
<http://www.opensymphony.com/ognl/html/LanguageGuide/coerceCollection.html>
says "Members of java.lang.Number are "walked" by returning integers
less than the given number starting with zero"
So if you have an OGNL expression %{#foo} that contains/results in the
value 7, then the OGNL expression %{#foo.{#this}} will result in the
list {0, 1, 2, 3, 4, 5, 6} over which you can iterate.
-Dale
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org