Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Stripes ActionBean HashMap

Posted on 2006-07-11
2
Medium Priority
?
2,379 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 1600 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
Take a look at these 6 Outlook Email management tools which can augment the working and performance of Microsoft Outlook to give you a more rewarding emailing experience.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Loops Section Overview

963 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