Ok, here is the Jira ticket:

https://issues.apache.org/struts/browse/WW-2984

I committed the changes to the iterator tag, here is how it works: New
attributes "begin", "end" and "step" were added. They can be used by
themselves, or with List and Arrays, like:

<s:iterator begin="1" end="5" step="2" >
...
<s:iterator begin="5" end="1" step="-1" >
...
<s:iterator begin="1" end="5" step="2" value="myList">
...
<s:iterator begin="5" end="1" step="-1" value="myArray">

Things to consider (let me make  sure that google gets this :)):

* When "values" is specified with "begin", then "value" must point to
a List or an Array
* The "end" attribute is inclusive, just like in JSTL, if a List/Array
is used, "end" is optional, and it will default to the size of the
List/Array, or to 0 if "step" is negative.
* If "step" is negative, then "begin" must be greater than "end"

I think that covers most of the use-cases. Testing is welcome (I added
a bunch of tests to IteratorTagTest).

musachy


On Thu, Feb 5, 2009 at 9:21 AM, Musachy Barroso <musa...@gmail.com> wrote:
> I agree with you, I don't use JSTL at all except forEach because of
> the few limitations of the iterator tag. I will take a look at it.
>
> regards
> musachy
>
> On Wed, Feb 4, 2009 at 9:45 PM, Ignacio de Córdoba <icord...@skios.es> wrote:
>>
>> Hi,
>> thanks for your reply.
>> Well... I have to iterate through a collection accesible in a struts2
>> Action. I can make that object visible to the page/request scope and then
>> access it from JSTL <c:forEach>; in fact I am doing that for dynamic images
>> as strugs2 has no IMG tag to use OGNL directly. Very painful when someone is
>> used to access the object from the tag itself. Moreover... I am really
>> trying to forget about EL and JSTL. I really don't find my self confortable
>> using 3 different expression languages / tag libs in my pages. I didn't have
>> to (in struts1) but maybe I have to accept that idea now.
>> Moreover, EL is obsolete when compared to OGNL (oh god... when I discovered
>> I could do #{people.size()} I just didn't believe it!!! Direct access to
>> methods. JSTL hasn't been improved for 4 (5?) years! Method access,
>> valuestack... and I am new to OGNL. Don't know 50% of its power!
>>
>> More situations: I made my HTML designers learn JSTL. Now I have to make
>> them learn OGNL and I am sure they'll have problems with both things mixed.
>> Of course, I'd like new people in the company thinking about the
>> presentation layer just to handle one thing.
>>
>> Why doesn't OGNL team focus on making it possible to forget about JSTL+EL
>> and just use OGNL for every thing? It nearly does!!!! and just because a
>> couple of minor glitches we can't. (Another example... s:a tag doesn't have
>> "target" attribute. I have then to use HTML   tag directly, what forces me
>> to transfer the href data in the Action to an object in the page scope and
>> use EL where. Painful for something that should be straightforward.
>>
>> Well... sorry for the long text. Please don't take me wrong. Just love
>> struts2 and would love to forget about old technnologies. I wish I had time
>> and knowledge to help on all this. Now I just can't.
>>
>>
>> newton.dave wrote:
>>>
>>> Ignacio de Córdoba wrote:
>>>> Hi there,
>>>> I've checked struts2 docs and this forum and have found no inside syntax
>>>> for
>>>> s:iterator tag to do:
>>>> <c:forEach var='' value='${}' being='1' end='4'/>
>>>>
>>>> Examples in docs just show how to count from 1 to 5 ¿? I'd like to avoid
>>>> counting and using indexed property to access an iterator. The last
>>>> example
>>>> in docs doesnt seem to work if I replace "this" with the property/objet I
>>>> want to iterate.
>>>>
>>>> I am sure struts2 team has thought of a way to do some partial iterator
>>>> (I
>>>> can also do the full iterator and do a s:if to show only 5 values using
>>>> status.index, but doesn't seem a nice solution.
>>>
>>> Any reason you can't use <c:forEach...>? <s:iterator doesn't have the
>>> same functionality.
>>>
>>> Dave
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>>> For additional commands, e-mail: user-h...@struts.apache.org
>>>
>>>
>>>
>>
>> --
>> View this message in context: 
>> http://www.nabble.com/s%3Aiterator-%C2%BFbegin--%3E-end--tp21832209p21844359.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>> For additional commands, e-mail: user-h...@struts.apache.org
>>
>>
>
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>



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

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

Reply via email to