Nov 8th, 2006, 06:56 AM
Supplying own object to text converter for labels in a combo
I've managed to bind my items to a combo and I can see them. Unfortunately, the items of type X can't have a toString().
How do I install an X->String converter for the combo in such a way that the strings are displayed in the combo, the typeahead sees them but when I use combo.getSelectedItem(), I still get an item of type X? Note that I need null elements (or at least a way to tell the combo that the user can select "nothing").
I had a look at PetTypeBinder but that's not what I want because there, getSelectedItem() returns a String, not X.
I tried to register a custom Converter (sourceClasses: X, targetClasses: String) but it's not used.
Next stop was to use a custom bindComboBox() which overwrites ComboBoxBinder.RENDERER_KEY and ComboBoxBinder.EDITOR_KEY. Unfortunately, these don't allow null values in the list of items.
I was thinking that this is such a common problem, that there must be a totally simple solution but after two days, I'm stuck.
Thanks a lot.
Last edited by Aaron Digulla; Nov 8th, 2006 at 07:47 AM.
Reason: Better title
Nov 16th, 2006, 02:26 AM
Does no one have an example how to create a combo with a list of objects which includes null and a custom renderer?