Results 1 to 2 of 2

Thread: Overwriting the texts in a combo

  1. #1
    Join Date
    Nov 2006
    Location
    Zurich
    Posts
    16

    Default Supplying own object to text converter for labels in a combo

    Hello,

    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

  2. #2
    Join Date
    Nov 2006
    Location
    Zurich
    Posts
    16

    Default

    Does no one have an example how to create a combo with a list of objects which includes null and a custom renderer?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •