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>