struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kris Schneider <k...@dotech.com>
Subject Re: How to iterate over two collections ?
Date Mon, 17 Nov 2003 19:05:06 GMT
I think the code I provided does what you were asking for, but maybe I'm missing
something. Perhaps adding comments to my example will help:

<%-- iterate through costMap, "entry" will be an instance of Map.Entry --%>
<%-- Map.Entry exposes two properties: "key" and "value"               --%>
<c:forEach var="entry" items="${costMap}">

  <%-- output value for costMap entry --%>
  <c:out value="${entry.value}"/>

  <%-- output value for volMap entry --%>
  <c:out value="${volMap[entry.key]}"/>

</c:forEach>

Quoting Vinita Keswani <vinitakeswani@yahoo.com>:

> Thanks but in any case I have to create an iterator to loop thru the
> maps.What I want to do is to have one loop and to pick up value entries from
> another - yes may be I can try using lookups using key???
> 
> Kris Schneider <kris@dotech.com> wrote:With JSTL:
> 
> 
> 
> 
> 
> 
> Quoting Brice Ruth 
> :
> 
> > You could loop over one collection, exposing the varStatus, which 
> > contains the key, and use the key to look up in the second map ... I
> think?
> > 
> > Vinita Keswani wrote:
> > 
> > >Hello,
> > > 
> > >Could anyone please tell me if there is a workaround for iterating over
> two
> > collections at the same time when both have the same key but different
> > values?
> > > 
> > >For eg: Descr, Cost,Volume....
> > >Two maps one is - costMap which has descr and cost
> > >and another one is - volMap which has descr and volume.
> > > 
> > >Please help
> > > 
> > >Vinita
> > >
> > >
> > >---------------------------------
> > >Do you Yahoo!?
> > >Protect your identity with Yahoo! Mail AddressGuard
> > > 
> > >
> > 
> > -- 
> > Brice D. Ruth
> > Sr. IT Analyst
> > Fiskars Brands, Inc.
> 
> -- 
> Kris Schneider 
> D.O.Tech 

-- 
Kris Schneider <mailto:kris@dotech.com>
D.O.Tech       <http://www.dotech.com/>

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


Mime
View raw message