<logic:iterate id="itemEntry" property="offerItems" name="someForm"
scope="session" >
<td valign="top">
<bean:write name="itemEntry" property="key"/>
</td>
<td valign="top">
<bean:write name="itemEntry" property="value.name" />
</td>
</logic:iterate>
should work.
--m
----- Original Message -----
From: "Nanduri, Amarnath" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, June 26, 2001 2:17 PM
Subject: RE: iterate over a HashMap
> Mike,
> Thanks a lot for your help. I am trying to figure out how to typecast
the
> 'value' object into type DataBean so that i can call one of its methods.
> Maybe i need to do something fancy to satisfy the compiler and the JVM.
>
> cheers,
> Amar..
>
> -----Original Message-----
> From: Mike Thompson [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, June 26, 2001 3:09 PM
> To: [EMAIL PROTECTED]
> Subject: Re: iterate over a HashMap
>
>
> Normally, each object exposed by the iterate tag is an element of the
> underlying collection you are iterating over. However, if you iterate over
a
> Map, the exposed object is of type Map.Entry that has two properties:
>
>
> a.. key - The key under which this item is stored in the underlying Map.
> b.. value - The value that corresponds to this key.
> So
> > <logic:iterate id="itemEntry" property="offerItems" name="someForm"
> > scope="session" >
>
> the property itemEntry.key is the key in the hashmap.
> the property itemEntry.value is your bean, which you may do something like
> itemEntry.value.name
>
> Hope this helps.
> --m
>
>
>
> ----- Original Message -----
> From: "Nanduri, Amarnath" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, June 26, 2001 2:01 PM
> Subject: iterate over a HashMap
>
>
> >
> > How do i iterate over a HashMap ? The key is a String but the value is
an
> > Object of a certain type (example .. com.agilquest.bean.DataBean ).
> >
> > I need to call a getter in the 'value i.e dataBean.getName() ;
> >
> > Below is the code i use...The value is calling the toString() of
DataBean.
> I
> > need to call the getName() of DataBean. thanks a lot.
> >
> > cheers,
> > Amar..
> >
> > <logic:iterate id="itemEntry" property="offerItems" name="someForm"
> > scope="session" >
> >
> >
> > <td valign="top"> <%-- show the key in the HashMap
> > --%>
> > <bean:write name="itemEntry"
> > property="key"/>
> >
> > </td>
> >
> > <td valign="top"> <%-- show the value i.e DataBean
> > and call its getName() --%>
> > <bean:write name="itemEntry"
> > property="value" />
> > </td>
> >
> >
> > </logic:iterate>