jQuery in Action, 2nd edition*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "<h:selectOneMenu> problem" Watch "<h:selectOneMenu> problem" New topic
Author

<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

regards,
Nirvan.
 
 
subject: <h:selectOneMenu> problem
 
Similar Threads
how to print values on jsp page fetched from servlet
Display Problem in html
problem in relative path in jsp page
Get data for child using jdom
SchemaLocation Error In Eclipse IDE