[Echo-list] FW: SelectField
Brought to you by:
tliebeck
From: Kelleher, M. <Mic...@Ni...> - 2003-12-30 14:38:17
|
Here is another fact I discovered about the SelectField behavior: SelectFields without a ListCellRenderer behave properly. SelectFields with ListCellRenderers do not behave properly. -----Original Message----- From: Kelleher, Michael Sent: Monday, December 29, 2003 3:03 PM To: Echo List (E-mail) Subject: SelectField After creating a new instance of a SelectField and populating its DefaultSelectFieldModel like thus: public void add(SelectField sf, java.util.List list) { if (sf == null) { return; } int iSize = (list == null ? -1 : list.size()); SelectFieldModel sfm = sf.getModel(); DefaultSelectFieldModel dsfm = (DefaultSelectFieldModel) sfm; for (int i=0; i<iSize; i++) { dsfm.add(list.get(i)); } } The component will ALWAYS reset its SelectedItemIndex to 0. This happens regardless of any Listeners that may or may not be added to it. For example, in one screen I do not set any Listeners on the SelectField. I then populate the SelectField using the above method, and then say I select Index 3. Then I click on a CheckBox that has a listener attached to it. This causes the screen to refresh itself, and my SelectField's Index is reset to Index 0. I can however, "trap" the Selected item by attaching a ItemListener. After the screen refreshing itself, and i do a getSelectedItem or Index, the Selected Item/Index is the one at Index 0. I would post more code, but there really isn't any other than when I instantiate the SelectField. +---------------------------------+ | Michael J. Kelleher | | Application Technical Specialist| | Nielsen Media Research | +---------------------------------+ |