struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cory D. Wiles" <kwy...@gmail.com>
Subject Re: Iterate Hashmap with s:iterate
Date Wed, 12 Sep 2007 19:10:17 GMT
Dave,
  Where did you find the documentation on the "pseudo-property"?

On 9/12/07, Dave Newton <newton.dave@yahoo.com> wrote:
>
> IIRC OGNL supplies a pseudo-property "keys" that will
> return a list of keys present in the map.
>
> --- Wesley Wannemacher <WesW@doubleatrailer.com>
> wrote:
>
> > If I remember correctly, to use the s:iterator tag,
> > you have to use an
> > object that has an 'iterator()' method. HashMap does
> > not implement
> > java.util.List...
> >
> > To iterate over a Hashmap, get the keyset
> > [tempMap.ketSet()] from it.
> > The keyset is a List and you can get an iterator
> > from there.
> >
> > -Wes
> >
> > -----Original Message-----
> > From: Cory D. Wiles [mailto:kwylez@gmail.com]
> > Sent: Wednesday, September 12, 2007 2:28 PM
> > To: user@struts.apache.org
> > Subject: Iterate Hashmap with s:iterate
> >
> > I have an action that returns a hash map that I need
> > to output both the
> > key and value, but I can't figure out how to access
> > each property with
> > s:iterate.  Any suggestions would help.
> >
> > The HashMap is being set in my action and returned
> > populated (verified
> > with <s:debug/>).
> >
> > // Action snippet
> > Iterator categoryPhysPropsItr =
> > getCategoryPhysProps().iterator();
> > Map tempMap                       = new HashMap();
> > tempMap                              = new
> > TreeMap();
> >
> >       while (categoryPhysPropsItr.hasNext()) {
> >         DruglistDrugproperty prop = new
> > DruglistDrugproperty();
> >         prop = (DruglistDrugproperty)
> > categoryPhysPropsItr.next();
> >
> >
> >
> tempMap.put(prop.getDruglistDrugclass().getDrugClassName(),
> > prop.getDrugService());
> >
> >       }
> >
> >       setDrugClassPropsSrvc(tempMap); // HashMap
> > that needs to be
> > iterated through // end Action Snippet
> >
> > // Display JSP
> > <s:iterator value="drugClassPropsSrvc"
> > status="status">
> >     Key (<s:property
> >
> value="%{drugClassPropsSrvc['+#status.index+'].value}/>")<br/>
> >     Value (<s:property
> >
> value="%{drugClassPropsSrvc['+#status.index+'].value}"/>)
> > <br/>
> > </s:iterator>
> >
> > // end Display JSP
> >
> > Thanks,
> > Cory
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > user-unsubscribe@struts.apache.org
> > For additional commands, e-mail:
> > user-help@struts.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message