Solved

Stripes ActionBean HashMap

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Short answer to this question: there is no effective WiFi manager in iOS devices as seen in Windows WiFi or Macbook OSx WiFi management, but this article will try and provide some amicable solutions to better suite your needs.
We have come a long way with backup and data protection — from backing up to floppies, external drives, CDs, Blu-ray, flash drives, SSD drives, and now to the cloud.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now