tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wendy Smoak <Wendy.Sm...@asu.edu>
Subject RE: What is the method of direct acces to an array element?
Date Fri, 25 Jun 2004 15:21:07 GMT
> From: Martin Cooper
> At the very least, you'll want to change the 'varStatus' 
> value to 'status' 
> and change the 'myLoopIndex' usage to 'status.index'. The 'varStatus' 
> attribute exposes a structure rather than an index.

Oops, yes, varStatus exposes a LoopTagStatus object:
http://java.sun.com/products/jsp/jstl/1.1/docs/api/javax/servlet/jsp/jst
l/core/LoopTagStatus.html

Not only can you figure out what iteration you're on, but you can ask it
whether this is the first or last item, which is useful for things like
comma delimited lists so you don't display a comma after the final item.

Try this:

<c:forEach items="${firstArray}" var="myItem" varStatus="status">
   <c:out value="${myItem}"/>
   <c:out value="${secondArray[status.index]}"/>
   <c:out value="${thirdArray[status.index]}"/>
</c:forEach>

-- 
Wendy Smoak
Application Systems Analyst, Sr.
ASU IA Information Resources Management 

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


Mime
View raw message