Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!
  • 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic