You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Vincent Peytavin <vi...@libertysurf.fr> on 2003/07/22 17:44:48 UTC
One loop for two arrays
Hello,
I have 2 arrays, where elements correspond, that's to say list1[i] go with
list2[i].
For example, imagine list1 stands for "names" and "list2" for "surnames".
names[0]=Peytavin surnames[0]=Vincent
names[1]=Jackson surnames[1]=Michael
...
The difficulty is to set in a variable 'surname' (<c:set>?) the element
value with index i (i being defined in the loop which handles "surnames"
list), in order to be able to manipulate 'surname' with the same possibility
as 'name'.
(I hope I'm clear!)
<c:forEach var="nom" items="${liste1}" varStatus="i">
// Something which puts in 'surname' the value of 'list2[i]'
</c:forEach>
Thanks for your help!
--
Vincent
Re: One loop for two arrays
Posted by Felipe Leme <t5...@sneakemail.com>.
On Tuesday 22 July 2003 01:50 pm, Kris Schneider kris-at-dotech.com |jakarta|
wrote:
> The type of the "varStatus" attribute is
> javax.servlet.jsp.jstl.core.LoopTagStatus. This interface exports a number
Yes, I know :(
> of properties, including "index" and "count". I think you need:
> <c:set var="surname" value="${list2[i.index]}"/>
I took the list2[i] approach from a scratch page I had used for tests. I guess
the getIndex() method is returned by default (or maybe my example was wrong
:-).
Anyway, you're right, the index property is the right way to do it...
Felipe
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
Re: One loop for two arrays
Posted by Kris Schneider <kr...@dotech.com>.
The type of the "varStatus" attribute is
javax.servlet.jsp.jstl.core.LoopTagStatus. This interface exports a number of
properties, including "index" and "count". I think you need:
<c:set var="surname" value="${list2[i.index]}"/>
Quoting Felipe Leme <t5...@sneakemail.com>:
> On Tuesday 22 July 2003 12:44 pm, Vincent Peytavin wrote:
>
> > <c:forEach var="nom" items="${liste1}" varStatus="i">
> > // Something which puts in 'surname' the value of 'list2[i]'
> >
> > </c:forEach>
>
>
> I think the "something" could be something like::
>
> <c:set var="surname" value="${list2[i]}"/>
>
> Is that what you want?
>
> Felipe
--
Kris Schneider <ma...@dotech.com>
D.O.Tech <http://www.dotech.com/>
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
Re: One loop for two arrays
Posted by Felipe Leme <t5...@sneakemail.com>.
On Tuesday 22 July 2003 12:44 pm, Vincent Peytavin wrote:
> <c:forEach var="nom" items="${liste1}" varStatus="i">
> // Something which puts in 'surname' the value of 'list2[i]'
>
> </c:forEach>
I think the "something" could be something like::
<c:set var="surname" value="${list2[i]}"/>
Is that what you want?
Felipe
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
Re: One loop for two arrays
Posted by Michael Duffy <du...@yahoo.com>.
Sounds like a Map might be more applicable - names as
keys, surnames as values.
--- Vincent Peytavin <vi...@libertysurf.fr>
wrote:
> Hello,
>
> I have 2 arrays, where elements correspond, that's
> to say list1[i] go with
> list2[i].
> For example, imagine list1 stands for "names" and
> "list2" for "surnames".
> names[0]=Peytavin surnames[0]=Vincent
> names[1]=Jackson surnames[1]=Michael
> ...
>
> The difficulty is to set in a variable 'surname'
> (<c:set>?) the element
> value with index i (i being defined in the loop
> which handles "surnames"
> list), in order to be able to manipulate 'surname'
> with the same possibility
> as 'name'.
> (I hope I'm clear!)
>
> <c:forEach var="nom" items="${liste1}"
> varStatus="i">
> // Something which puts in 'surname' the value of
> 'list2[i]'
>
> </c:forEach>
>
> Thanks for your help!
>
> --
> Vincent
>
>
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org