jQuery in Action, 2nd edition*
The moose likes JSF and the fly likes How to populate elements in selectManyListbox as selected Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How to populate elements in selectManyListbox as selected" Watch "How to populate elements in selectManyListbox as selected" New topic
Author

How to populate elements in selectManyListbox as selected

Venu Babu Ravi
Greenhorn

Joined: Jun 08, 2010
Posts: 16


Can any one help me how to populate elements in selectManyListbox with elements as selected?

I have following code in jsp.
-------------------------------

I have following code in Bean
---------------------------------


The property name is vendorCategory.

i am able to populate the data in selectManyListbox but it is not showing as selected.

Thanks in advance...


venubabu.ravi
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15960
    
  19

Venu! at last I've found someone who does more method chaining than I do!

Seriously, you might want to break some of that code down into smaller sequences. It makes it more readable, and if you're using a debugger it's easier to follow the data. Nothing is more annoying than a NullPointerException that could have come from somewhere in a sequence of method calls, but you don't know which method call returned null.

There's a "Code" button on the JavaRanch message editor that can help make your code examples more readable. I've edited your message to include it.

The selectOne/SelectMany JSF controls cannot take a simple array or list of Strings. That's because there are 2 separate data elements that go into the generated HTML <SELECT> option elements - one for the display value and one for the returned data value. So you have to build up a collection of JSF SelectItem objects to serve as the display model for those controls.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to populate elements in selectManyListbox as selected
 
Similar Threads
Selecting some entries in selectManyListbox
selectManyListbox Issue
selectManyListbox not setting value
selectManyListBox not binding to an arraylist
selectManyListbox