So , here is an example.
What I want is, that if I change the value of an inputfield (edit the value and press enter)the Label should be automatically updated. The formula of the Labels value is in the CalcDTO Class. Is there a way to do this automatically?
Code:
package de.globus.fma.client.main;import com.google.gwt.user.client.rpc.IsSerializable;
public class CalcDTO implements IsSerializable {
private long field1;
private long field2;
public CalcDTO() {
super();
}
public CalcDTO(long value1, long value2) {
this.field1 = value1;
this.field2 = value2;
}
public long getField1() {
return field1;
}
public void setField1(long field1) {
this.field1 = field1;
}
public long getField2() {
return field2;
}
public void setField2(long field2) {
this.field2 = field2;
}
public String getResult() {
return "" + (field1 * field2);
}
}
Code:
package de.globus.fma.client.main;import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.editor.client.Editor;
import com.google.gwt.editor.client.SimpleBeanEditorDriver;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.form.NumberField;
import com.sencha.gxt.widget.core.client.form.NumberPropertyEditor.LongPropertyEditor;
public class CalcView implements EntryPoint, Editor<CalcDTO>{
interface CalcDriver extends SimpleBeanEditorDriver<CalcDTO, CalcView> {}
private CalcDriver driver;
private CalcDTO calc;
NumberField<Long> field1;
NumberField<Long> field2;
Label result;
public void onModuleLoad() {
driver = GWT.create(CalcDriver.class);
calc = new CalcDTO(10,10);
VerticalLayoutContainer vlc = new VerticalLayoutContainer();
field1 = new NumberField<Long>(new LongPropertyEditor());
field2 = new NumberField<Long>(new LongPropertyEditor());
result = new Label();
vlc.add(field1);
vlc.add(field2);
vlc.add(result);
driver.initialize(this);
driver.edit(calc);
RootPanel.get().add(vlc);
}
}