This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JSF and the fly likes Need to display the value from a map as a label in a drop down using <h:selectOneMenu> Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Need to display the value from a map as a label in a drop down using <h:selectOneMenu>" Watch "Need to display the value from a map as a label in a drop down using <h:selectOneMenu>" New topic
Author

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

Achala pra
Greenhorn

Joined: Feb 16, 2011
Posts: 2
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;
static{
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}" />
</h:selectOneMenu>

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
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Need to display the value from a map as a label in a drop down using <h:selectOneMenu>
 
Similar Threads
CSS for individual selectItem tag
Doubt in ajax4jsf
selected value through select items
Regarding accessing of enum declared inside and outside a class
CSS for individual selectItem tag