SmartGWT 4.1
SmartClient Version: v9.1p_2014-11-09/PowerEdition Deployment (built 2014-11-09)
I have created a very simple form that makes use of nested fields. When I programattically call setValues for fields that are nested they update in the UI as expected, however for fields that contain nested values they do not. I am curious what the proper methodology is, and if I am truly expected to tell these form items to redraw?
nested object ds
SimpleForm.java -- Nested object fields do not update without redrawing FormItems
SmartClient Version: v9.1p_2014-11-09/PowerEdition Deployment (built 2014-11-09)
I have created a very simple form that makes use of nested fields. When I programattically call setValues for fields that are nested they update in the UI as expected, however for fields that contain nested values they do not. I am curious what the proper methodology is, and if I am truly expected to tell these form items to redraw?
nested object ds
Code:
<DataSource beanClassName="simpleNestedObject" ID="SimpleNestedObject"> <fields> <field name="a" type="float"/> <field name="b" type="float"/> <field name="c" type="text"/> </fields> </DataSource>
Code:
public class SimpleForm extends VLayout { private final DynamicForm form; public SimpleForm() { form = new DynamicForm(); form.setDataSource(new DataSource() { public DataSource init() { DataSourceField nested = new DataSourceField(); nested.setName("nested"); nested.setTypeAsDataSource(DataSource.get("SimpleNestedObject")); DataSourceField outerA = new DataSourceField("outerA", FieldType.Float); DataSourceField outerB = new DataSourceField("outerB", FieldType.Float); setFields(nested, outerA, outerB); return this; } }.init()); FormItem innerA = new FormItem("a"); innerA.setDataPath("nested/a"); FormItem innerB = new FormItem("b"); innerB.setDataPath("nested/b"); FormItem c = new FormItem("c"); c.setDataPath("nested/c"); FormItem outerA = new FormItem("outerA"); FormItem outerB = new FormItem("outerB"); form.setFields(innerA, innerB, c, outerA, outerB); } public void setNested(Record nested) { form.setValue("nested", nested); //to get nested values to update for(FormItem field : form.getFields()) { field.redraw(); } } public void setOuter(double a, double b) { form.setValue("outerA", a); form.setValue("outerB", b); } }
Comment