File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes <h:selectOneMenu> problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "<h:selectOneMenu> problem" Watch "<h:selectOneMenu> problem" New topic

<h:selectOneMenu> problem

Joe Richard
Ranch Hand

Joined: Aug 15, 2001
Posts: 76
Hi all,

I am trying to use a javaBean to pull data and populate a someList<someObject>.
I want to use JSTL this is what I have that doesn't work.

<f:selectItems id="#{javaBean.someList.someObject.field1}" itemLabel="#{javaBean.someList.someObject.field2}" itemValue="#{javaBean.someList.someObject.field1}"/>

Any ideas how to do this with jsf?

Persistence equals goals
SCJD (In Progress), SCJP
B Nirvan
Ranch Hand

Joined: Oct 20, 2010
Posts: 82
In JSF one way to do is create a List of SelectItems and point the value attribute of the f:SelectItems to that list. Here is sample code

<f:selectItems value="#{stateBean.stateList}"/>

stateList is a backing bean property defined as

List<SelectItem> stateList;

You can also bind the value directly to your List instead of using List<SelectItems>, but it seems you don't get to define different values for itemLabel and itemValue. I am not very sure about this approach though

I agree. Here's the link:
subject: <h:selectOneMenu> problem
jQuery in Action, 3rd edition