You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Rick Reumann <st...@reumann.net> on 2004/10/05 04:46:12 UTC

Re: Display a list contained in value of a TreeMap

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