You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Phani <ph...@yahoo.com> on 2004/10/05 04:00:50 UTC

Display a list contained in value of a TreeMap

Hi,

I got a TreeMap structure in my FormBean. Each key in
the TreeMap has got an ArrayList as its value.

Please let me know how to display the keys as well as
the list of values for each key in the JSP page.

TreeMap map;

ArrayList items = (ArrayList)map.get(key);

The ArrayList "items" now contains a string of
objects.

I need to display the key as well the items in the JSP
page.

Thanks.
 


		
__________________________________
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
http://mobile.yahoo.com/maildemo 

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


Re: Display a list contained in value of a TreeMap

Posted by Rick Reumann <st...@reumann.net>.
Phani wrote the following on 10/4/2004 10:00 PM:

> I got a TreeMap structure in my FormBean. Each key in
> the TreeMap has got an ArrayList as its value.
> 
> Please let me know how to display the keys as well as
> the list of values for each key in the JSP page.
> 
> TreeMap map;
> 
> ArrayList items = (ArrayList)map.get(key);
> 
> The ArrayList "items" now contains a string of
> objects.
> 
> I need to display the key as well the items in the JSP
> page.

Not tested below but should be ok. the .?? is because I don't know what 
kind of Objects are in the List. If they are beans in the ArrayList just 
.whateverProperty where whateverProperty of course equates to a getter 
(getWhateverProperty() in the bean)

<c:forEach items="${yourFormBean.yourMap}" var="map">
     The Key: <c:out value="${map.key}"/><br/>
     <c:forEach items="${map.value}" var="item">
	Item in List: <c:out value="${item(.??)}/><br/>
     </c:forEach>
</c:forEach>


-- 
Rick

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