SmartClient Version: v10.0p_2015-09-24/Pro Deployment (built 2015-09-24)
I just found a strange bug where my ComboBoxItem returns the wrong record with getSelectedRecord().
I happens if the displayValue is the same for some of the records in the picklist.
I have attached a test-case below that illustrates the problem. The comboboxitem has it's value set to 3 when data arrives from the datasource, but if you press the button to read the value of the selected record, it returns 1.
My real comboboxitem is databound to a datasource with user submittet items so it is very likely that more than one item will have the same display value in my case.
TEST CASE:
TestDS:
test.data.xml
I just found a strange bug where my ComboBoxItem returns the wrong record with getSelectedRecord().
I happens if the displayValue is the same for some of the records in the picklist.
I have attached a test-case below that illustrates the problem. The comboboxitem has it's value set to 3 when data arrives from the datasource, but if you press the button to read the value of the selected record, it returns 1.
My real comboboxitem is databound to a datasource with user submittet items so it is very likely that more than one item will have the same display value in my case.
TEST CASE:
Code:
final VLayout mainLayout = new VLayout(); final ComboBoxItem item = new ComboBoxItem(); item.setOptionDataSource(TestDS.getInstance()); item.setDisplayField("name"); item.setValueField("id"); item.setAutoFetchData(true); item.addDataArrivedHandler(new DataArrivedHandler() { @Override public void onDataArrived(DataArrivedEvent event) { item.setValue(3); } }); Button b2 = new Button("Read Value"); b2.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { SC.say("value is: " + item.getSelectedRecord().getAttributeAsInt("id")); } }); mainLayout.addMember(b2); DynamicForm form = new DynamicForm(); form.setItems(item); mainLayout.addMember(form); mainLayout.draw();
Code:
public class TestDS extends DataSource { private static TestDS instance = null; public static TestDS getInstance() { if (instance == null) { instance = new TestDS("testDS"); } return instance; } public TestDS(String id) { setID(id); setRecordXPath("/List/testItem"); DataSourceIntegerField valueField = new DataSourceIntegerField("id"); valueField.setPrimaryKey(true); DataSourceTextField displayField = new DataSourceTextField("name"); setFields(valueField, displayField); setDataURL("ds/test.data.xml"); setClientOnly(true); } }
Code:
<List> <testItem> <id>1</id> <name>Test</name> </testItem> <testItem> <id>2</id> <name>Test</name> </testItem> <testItem> <id>3</id> <name>Test</name> </testItem> <testItem> <id>4</id> <name>Test</name> </testItem> </List>
Comment