Menu

Need Help on Using YComboBox

Help
stjauns
2007-07-02
2013-04-08
  • stjauns

    stjauns - 2007-07-02

    setComboModel() is a Collection of POJO have 3 fields: [code], [name], [para]. and I set the modelField to [code], the Formatter displays the [name].

    How could I get the selectd [para] easily?

    I did checked the TikeSwing - User's Guide document and noticed that the YIExtendedModelComponent maybe the key, but i did not found how to uses this feature...

     
    • Tomi Tuomainen

      Tomi Tuomainen - 2007-07-02

      Using YIExtendedModelComponent feature in YComboBox is just an alternate way of initializing combo model. You can call setComboModelField instead of callling setComboModel (see Javadoc). So that won't help you directly.

      But what you can do to read your [para] is, that you don't set modelField at all. In this case, the selected item will be the whole POJO. So you must have "private MyPOJO selectedPOJO" in your YModel (not any field for [code] anymore).

      Or then, not so clean way is to use the following code...

      YListItem comboItem = (YListItem) myCombo.getSelectedItem();
      MyPOJO selectedPojo = comboItem.getItemModel();

      Tomi

       
    • stjauns

      stjauns - 2007-07-03

      Thanks for your help.

       

Log in to post a comment.