aspose file tools*
The moose likes JSF and the fly likes Can't get JSF selectOneMenu to show list of items Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Can Watch "Can New topic
Author

Can't get JSF selectOneMenu to show list of items

Phillip Ankerson
Greenhorn

Joined: Aug 10, 2011
Posts: 27

First, I welcome suggestions on a good JSF book. I'm trying to learn this stuff, it's great but massive.

I have a managed bean to retrieve a list of items from a database, and a jsf page to display the dropdown list as a selectOneMenu. The items don't show up in the drop down. Suggestions?

JSF page


Managed Bean


Pacor Entity Class
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16139
    
  21

The correct form of the f:selectItem for multiple values is:


where the corresponding value property accessor has the form:


An array of SelectItem objects is also possible. The selectItem model objects contain not only label/value pairs used to build the select options, but also additional option information as well.


Customer surveys are for companies who didn't pay proper attention to begin with.
Phillip Ankerson
Greenhorn

Joined: Aug 10, 2011
Posts: 27

So my bean code public List<Pacor> getCores() {

should read public List<SelectItem> getCores() { ?

I think I have the rest of it...unless I'm missing something.

Thanks Tim.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16139
    
  21

Phillip Ankerson wrote:So my bean code public List<Pacor> getCores() {

should read public List<SelectItem> getCores() { ?

I think I have the rest of it...unless I'm missing something.

Thanks Tim.


Phillip Ankerson
Greenhorn

Joined: Aug 10, 2011
Posts: 27

I made that change but it still doesn't populate any values from the database. I'm not sure what to do next.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can't get JSF selectOneMenu to show list of items