You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Anton Pussep <an...@pussep.de> on 2007/06/11 00:43:26 UTC
In a merged iterator, know which iterator current item belongs
Hello,
I want to successively call several iterators. This works perfectly fine
with a merged iterator, but now I need to know to which iterator the
currently processed entry belongs to, since they have to be treated
differently.
See the small example below that illustrates my intention. Currently I
just check if the current entry is an odd number or not, but this does
not work if numbers.length>operators.length+1 or even
operators.length<numbers.length; do you have any suggestion how to solve
this?
<s:merge id="mergedIterator">
<s:param value="numbers" />
<s:param value="operators" />
</s:merge>
<s:iterator value="%{#mergedIterator}" status="iterStatus">
<s:if test="#iterStatus.odd">
NUMBER
</s:if>
<s:else>
OPERATOR
</s:else>
</s:iterator>
Thanks,
Anton
Re: In a merged iterator, know which iterator current item belongs
Posted by Dave Newton <ne...@yahoo.com>.
--- Anton Pussep <an...@pussep.de> wrote:
> In this case numbers is of type double[] and
> operators is of type String[]. Would be great if you
> could tell me how to check for the type.
OGNL.
<s:if test="#foo.class.name == 'java.lang.String'">
d.
____________________________________________________________________________________
Bored stiff? Loosen up...
Download and play hundreds of games for free on Yahoo! Games.
http://games.yahoo.com/games/front
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: In a merged iterator, know which iterator current item belongs
Posted by Anton Pussep <an...@pussep.de>.
>> but now I need to know to which iterator the
>> currently processed entry belongs to, since they
>> have to be treated differently.
>
> Are the items of the same type?
>
> If so, I'm not sure what you can do.
>
In this case numbers is of type double[] and operators is of type
String[]. Would be great if you could tell me how to check for the type.
Actually I thought of another solution. If not using tags but JSP I
would write:
for(int i=0; i<Math.max(numbers.length, operators.length); i++) {
// check if index exists for numbers and print out "NUMBER"
// check if index exists for operators and print out "OPERATOR"
}
And I think it is possible to write the same peace of code with tags.
But would you recommend me to go with tags or use JSP?
Best,
Anton
Re: In a merged iterator, know which iterator current item belongs
Posted by Dave Newton <ne...@yahoo.com>.
--- Anton Pussep <an...@pussep.de> wrote:
> but now I need to know to which iterator the
> currently processed entry belongs to, since they
> have to be treated differently.
Are the items of the same type?
If so, I'm not sure what you can do.
d.
____________________________________________________________________________________
8:00? 8:25? 8:40? Find a flick in no time
with the Yahoo! Search movie showtime shortcut.
http://tools.search.yahoo.com/shortcuts/#news
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org