Sorry for my english...
Good afternoon, I found a bug related to ComboBoxItem component.
It added a default value for the ComboBox component and this value is zero (0), to the navigate with the tab key on the component, the field data are clean.
This happens because the zero (0) value is being compared to an empty string (""), and in javascript return true:
The error was found in the FormItem class, this line:
Here is the test case:
I found this bug on:
SmartClient Version: v9.1p_2014-04-29/LGPL Development Only (built 2014-04-29);
Good afternoon, I found a bug related to ComboBoxItem component.
It added a default value for the ComboBox component and this value is zero (0), to the navigate with the tab key on the component, the field data are clean.
This happens because the zero (0) value is being compared to an empty string (""), and in javascript return true:
Code:
0 == "" is true;
Code:
7781. if (result == value && result == this.emptyDisplayValue) {
Code:
public class Entry implements EntryPoint {
private VLayout contentPanel;
private DynamicForm dynamicForm;
private TextItem firstField;
private ComboBoxItem comboBoxItem;
private TextItem secondField;
private TestDataSource testDataSource;
@Override
public void onModuleLoad() {
getContentPanel().draw();
}
private VLayout getContentPanel() {
if (contentPanel == null) {
contentPanel = new VLayout();
contentPanel.setHeight100();
contentPanel.setWidth100();
contentPanel.addMembers(getDynamicForm());
}
return contentPanel;
}
public DynamicForm getDynamicForm() {
if (dynamicForm == null) {
dynamicForm = new DynamicForm();
dynamicForm.setItems(getFirstTextItem(), getComboBoxItem(), getSecondTextItem());
}
return this.dynamicForm;
}
public TextItem getFirstTextItem() {
if (firstField == null) {
firstField = new TextItem("textItem01", "First");
}
return firstField;
}
public TextItem getSecondTextItem() {
if (secondField == null) {
secondField = new TextItem("textItem02", "Second");
}
return secondField;
}
public ComboBoxItem getComboBoxItem() {
if (comboBoxItem == null) {
comboBoxItem = new ComboBoxItem("test", "Test");
comboBoxItem.setAddUnknownValues(false);
comboBoxItem.setCompleteOnTab(true);
comboBoxItem.setRequired(true);
comboBoxItem.setValueField("id");
comboBoxItem.setDisplayField("name");
comboBoxItem.setFilterFields("name");
comboBoxItem.setSortField("name");
comboBoxItem.setDefaultValue(0L);
comboBoxItem.setDefaultToFirstOption(true);
comboBoxItem.setOptionDataSource(getTestDataSource());
}
return this.comboBoxItem;
}
public TestDataSource getTestDataSource() {
if (testDataSource == null) {
testDataSource = new TestDataSource();
}
return this.testDataSource;
}
public static class TestDataSource extends DataSource {
private static final String ID = "TEST_DATASOURCE";
public TestDataSource() {
setID(ID);
setDataProtocol(DSProtocol.CLIENTCUSTOM);
}
@Override
protected Object transformRequest(final DSRequest dsRequest) {
if (dsRequest.getOperationType() == DSOperationType.FETCH) {
// Simulates a roundtrip to server
Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
@Override
public boolean execute() {
DSResponse dsResponse = new DSResponse(ID, DSOperationType.FETCH);
Record record_01 = new Record();
record_01.setAttribute("id", 0L);
record_01.setAttribute("name", "Brasil");
Record record_02 = new Record();
record_02.setAttribute("id", 1L);
record_02.setAttribute("name", "Argentina");
Record record_03 = new Record();
record_03.setAttribute("id", 2L);
record_03.setAttribute("name", "México");
dsResponse.setData(record_01, record_02, record_03);
dsResponse.setStatus(RPCResponse.STATUS_SUCCESS);
processResponse(dsRequest.getRequestId(), dsResponse);
return false;
}
}, 1000);
}
return dsRequest.getData();
}
}
}
SmartClient Version: v9.1p_2014-04-29/LGPL Development Only (built 2014-04-29);