This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes JSF and the fly likes selectOneListbox and converters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "selectOneListbox and converters" Watch "selectOneListbox and converters" New topic

selectOneListbox and converters

Juan Med�n

Joined: Sep 22, 2003
Posts: 4

Based on the documentation, you must write a converter for each custom object you wish to show in a selectOneListBox. This means that if you have a simple business object as:

public class Country {
private int _code;
private String _name;

// Getters and setters

You can't just create a list of SelectItem's to feed it. Ex.:

Country testCountry = new Country("Germany", 100);
SelectItem si1 = new SelectItem(testCountry, testCountry.getName());

and then a setter in your backing bean like:

public void setCountry(Country c) { /* code */ }

It seems to me that JSF should handle the conversion, since it has all the info it needs to do it. Otherwise, it'd mean that, for a model with 100+ business objects, you should write 100+ converters.

I'm sure I'm missing something. Do you know if is it possible to use the selectOneListBox this way ? Any comment would be really welcome.

Best regards,

- Juan
I agree. Here's the link:
subject: selectOneListbox and converters
jQuery in Action, 3rd edition