It's not a secret anymore!
The moose likes JSF and the fly likes <h:selectOneMenu> problem Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSF
Reply 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.
 
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: <h:selectOneMenu> problem
 
Similar Threads
problem in relative path in jsp page
Get data for child using jdom
SchemaLocation Error In Eclipse IDE
how to print values on jsp page fetched from servlet
Display Problem in html