aspose file tools*
The moose likes JSF and the fly likes Question with selectOneMenu Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Question with selectOneMenu" Watch "Question with selectOneMenu" New topic
Author

Question with selectOneMenu

Jesse Felter
Greenhorn

Joined: Aug 23, 2004
Posts: 17
I have a quick question, is there any easy way to append to the beginning of a select menu. Meaning I have a list that comes out of the bean of items, but at the top of the menu I want it to say ALL ITEMS. Is there an easy way to add the ALL ITEMS at the front of the list and have the value set to "all"

code:

<h:selectOneMenu rendered="#{userDataBean.user && !ReportDataBean.reportListEmpty}"
value="#{ReportDataBean.item}"
styleClass="optionValue">

<f:selectItems value="#{itemDataBean.itemList}"/>
</h:selectOneMenu>

so this makes a menu list of all the items out of the bean, however I want to avoid adding in the the ALL ITEMS option in the bean because its used by other applications that do not need it.

Thanks for the help in advance
Prakash Jebaraj
Greenhorn

Joined: Mar 14, 2005
Posts: 5
Hi Jesse,

You can add f:selectItem before f:selectItems tag like the following

<h:selectOneMenu rendered="#{userDataBean.user && !ReportDataBean.reportListEmpty}" value="#{ReportDataBean.item}" styleClass="optionValue">
<f:selectItem itemLabel="ALL ITEMS " itemValue="all" id="allItems"/>
<f:selectItems value="#{itemDataBean.itemList}"/>
</h:selectOneMenu>

Prakash
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Question with selectOneMenu