• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

html:options Hashmap

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a Map in session and i want to populate the drop down element with the values in the Map. I am to able do it with List in session.

some thing like
<html:select property="Reports" >
<html ptions name = "collectionname" />
</html:select>

Now i have a Map in seession like
myMap.put("1" ,"Robert");
myMap.put("2", "David");
mymap.put("3", "Edward");

and i want my drop down to have values populated with keys of map like 1, 2, 3.

can anyone help me how to acheve this using
html ptions , I appreciate any inputs.
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use this:

<html-el:select property="Reports" >
<c:forEach var="curmyMap" items="${myMap}">
<html-el ption value="${curmyMap.key}"><c ut value="${curmyMap.value}"/></html-el ption>
</c:forEach>
</html-el:select>

It should also work with html:select....
:roll:
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This should also work:

<html:options collection="myMap" property="key" labelProperty="value" />

When Struts iterates through any implementation of the java.util.Map interface, each entry is of type Map.Entry, which has a key and a value property.
 
kiran kumar
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your input
<html ptions ... /> worked out.
 
Are we home yet? Wait, did we forget the tiny ad?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic