wood burning stoves 2.0*
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
JavaRanch » Java Forums » Java » JSF
Bookmark "selectOneListbox and converters" Watch "selectOneListbox and converters" New topic
Author

selectOneListbox and converters

Juan Med�n
Greenhorn

Joined: Sep 22, 2003
Posts: 4
Hi,

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: http://aspose.com/file-tools
 
subject: selectOneListbox and converters
 
Similar Threads
Create a Different selectOneListbox Depending On the Radio Button Clicked
problem when working with selectOneListbox
Help - question on selectOneListbox and page reloads
selectOneListbox value from an ArrayList
problem with SelectOneListbox