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...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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...
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...
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
Thanks for your help.