In the following testcase i have a selectItem with an inputtransformer (in this case it's really trivial). Now when changing the value of this selectitem no change handlers are fired. Neither is form.getValues() updated with the new value of the selectitem.
This seemed to happen only when I defined the datasourcefields myself, and not when I loaded them from an xml datasource.
When I remove the inputtransformer, the events get fired fine and getValues() is updated properly.
This was tested on SmartClient Version: SC_SNAPSHOT-2010-11-15/PowerEdition Deployment (built 2010-11-15) with GWT 2.0.4 on firefox 3.6.12
This seemed to happen only when I defined the datasourcefields myself, and not when I loaded them from an xml datasource.
When I remove the inputtransformer, the events get fired fine and getValues() is updated properly.
This was tested on SmartClient Version: SC_SNAPSHOT-2010-11-15/PowerEdition Deployment (built 2010-11-15) with GWT 2.0.4 on firefox 3.6.12
Code:
package test.client; import java.util.Map; import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.FormItemInputTransformer; import com.smartgwt.client.widgets.form.fields.FormItem; import com.smartgwt.client.widgets.form.fields.SelectItem; import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; import com.smartgwt.client.widgets.layout.HLayout; public class InputValueTransformerTest implements EntryPoint { public void onModuleLoad() { final DynamicForm form = new DynamicForm(); form.setDataSource(MyTestDatasource.getInstance()); SelectItem firstSelectItem = new SelectItem("cntn_fk_customer", "Customer"); firstSelectItem.setOptionDataSource(DataSource.get("Customer")); firstSelectItem.setInputTransformer(new FormItemInputTransformer() { @Override public Object transformInput(DynamicForm form, FormItem item, Object value, Object oldValue) { return value; } }); firstSelectItem.setDisplayField("cstm_name"); firstSelectItem.addChangedHandler(new ChangedHandler() { @Override public void onChanged(ChangedEvent event) { System.err.println("firstSelectItem changed"); } }); form.setFields(firstSelectItem); IButton button = new IButton(); button.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { System.err.println("onClick"); for(Map.Entry<String, Object> entry: ((Map<String,Object>)form.getValues()).entrySet()) { System.err.println(entry.getKey() + " => " + entry.getValue()); } } }); HLayout layout = new HLayout(); layout.addMember(form); layout.addMember(button); layout.draw(); } }
Code:
package test.client; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.Record; import com.smartgwt.client.data.fields.DataSourceIntegerField; public class MyTestDatasource extends DataSource { private static MyTestDatasource instance = null; public static MyTestDatasource getInstance() { if (instance == null) { instance = new MyTestDatasource("testDataSource"); } return instance; } public MyTestDatasource(String id) { setID(id); setClientOnly(true); DataSourceIntegerField dynamicField = new DataSourceIntegerField("cntn_fk_customer", "Customer", 10, false); setFields(dynamicField); Record record = new Record(); record.setAttribute("cntn_fk_customer", 1); addData(record); } }
Code:
<DataSource serverType="sql" dbName="Mysql" tableName="Customer" ID="Customer" > <fields> <field primaryKey="true" type="sequence" name="cstm_pk" hidden="true"></field> <field type="text" length="45" name="cstm_name" title="" required="true" export="true"></field> </fields> </DataSource>
Comment