This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma 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


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: 17038
    
  26

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: 17038
    
  26

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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Can't get JSF selectOneMenu to show list of items
 
jQuery in Action, 3rd edition