Solved

Stripes ActionBean HashMap

Posted on 2006-07-11
2
2,339 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
unit test DAO layer 1 142
maven webservice projet error 6 80
JavaScript parse form with colon separated values 2 78
how to add new optional parameter to JSP 1 55
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In order to fulfill our mission of inspiring learning in the technology community, Experts Exchange is launching a Course of the Month program. Premium and Team Account members will have access to one course per month as a part of their membership, …

733 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