Solved

Stripes ActionBean HashMap

Posted on 2006-07-11
2
2,355 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

631 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