File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Question with selectOneMenu

Jesse Felter

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"


<h:selectOneMenu rendered="#{userDataBean.user && !ReportDataBean.reportListEmpty}"

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

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

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}"/>

I agree. Here's the link:
subject: Question with selectOneMenu
It's not a secret anymore!