• Post Reply Bookmark Topic Watch Topic
  • New Topic

selectOneListbox and converters  RSS feed

Juan Med�n
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!