Solved

Stripes ActionBean HashMap

Posted on 2006-07-11
2
2,333 Views
Last Modified: 2007-12-19
How can i loop through a HashMap<String, ArrayList> myHash on my jsp withouth having the size of hashMap<String, ArrayList> as a bean.
e.g: <c:forEach items="${myHash}[ key ]" var="values" >// values is an arrayList
0
Comment
Question by:komlaaa
2 Comments
 
LVL 3

Expert Comment

by:anumalas
ID: 17097054
Hi

You can use logic:iterate to loop  see the bellow example

<logic:iterate id="IdofYourBean" name="hashMap">
           <option value="<bean:write name="IdofYourBean" property="key"/>">
                      <bean:write name="BatchView" property="value"/>
           </option>
</logic:iterate>  

Note: Before using bean id use <bean:define> to define the property. And HashMap property should be in your bean with getter and setters.


Hope this will solve your problem :)

For further information on logic:iterate follow the link

http://www.jajakarta.org/struts/struts1.0/en/target/documentation/struts-logic.html

0
 
LVL 29

Accepted Solution

by:
bloodredsun earned 400 total points
ID: 17110960
JSTL is far better to use than the logic library. In fact the struts developers recommend it.

Iterating over a map is very simple

<c:forEach var='item' items='${map}'>
   <c:out value='Key=${item.key}, Value=${item.value}'/>
</c:forEach>

If the value is an ArrayList as you say then you just do another c:forEach on the value returned by item.value.

<c:forEach var='mapItem' items='${map}'>
   <c:forEach var='myListItem' items=${mapItem.value}'>
      <c:out value='${myListItem}'/>
   </c:forEach>
</c:forEach>


0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
reflection example 3 112
dynamic reloading of jsp in jetty 2 121
print map entry 34 72
web application structure 18 100
This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
This article explains the steps required to use the default Photos screensaver to display branding/corporate images
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa‚Ķ

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question