Win a copy of Pragmatic AI this week in the Artificial Intelligence 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 all forums
this forum made possible by our volunteer staff, including ...
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Need to display the value from a map as a label in a drop down using <h:selectOneMenu>  RSS feed

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Need to display the value from a map using <h:selectOneMenu>
I am using primefaces 2.2 and have the following issue regarding <h:selectOneMenu>

I have a bean with following data...

public String favCoffee2;

//Generated by Map
private static Map<String,Object> coffee2Value;
coffee2Value = new LinkedHashMap<String,Object>();
coffee2Value.put("Coffee2 - Cream Latte", "Cream Latte"); //label, value
coffee2Value.put("Coffee2 - Extreme Mocha", "Extreme Mocha");
coffee2Value.put("Coffee2 - Buena Vista", "Buena Vista");

public Map<String,Object> getFavCoffee2Value() {
return coffee2Value;

The following is the code in my xhtml file...

Generated by Map :
<h:selectOneMenu value="#{user.favCoffee2}">
<f:selectItems value="#{user.favCoffee2Value}" />

But looks like it always takes the key from the map to display the label in a drop-down.
Is there another way to display the value of a map ?Top Delete postReport this postReply with quoteEdit post
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!