This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 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: 17149
    
  27

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.


An IDE is no substitute for an Intelligent Developer.
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: 17149
    
  27

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
 
It's not a secret anymore!