com.google.gwt.user.*
com.google.gwt.dom.client.*
public class Test
implements Serializable {
private Integer id;
private String name;
private float area;
}
Hi,I am trying to use the GWT editor framework to support data binding in my application. While implementing it I ran into a few issues and have a couple of questions regarding the same:1) Some of these components don't use
com.google.gwt.user.*
rather they use
com.google.gwt.dom.client.*
For e.g. InputElement as opposed to TextBox. Is it possible to use editor framework with dom elements?
2) Is it possible to bind POJO's with different field types (int, float, String, etc.) to a single Composite implementing IsEditor?For e.g. if there is an Input composite (wrapping TextBox), is it possible to use the same composite for POJO fields of different types int, float, etc. ?
public class Test
implements Serializable {
private Integer id;
private String name;
private float area;
}
Here name and area are of different type. Is it possible to bind these to the same widget implementing Editor (without editor I would just parse the values to and from String to their respective types before saving the data)?
public class InputEditor<T>
extends Input
implements LeafValueEditor<T> {
@UiConstructor
public InputEditor(String label, InputSize size, InputType type) {
super(label, size, type);
}
private T value;
@Override
public T getValue() {
String theTextValue = getText();
Object theGenericValue = theTextValue;
if (value instanceof Integer) {
theGenericValue = Integer.parseInt(theTextValue);
} else if (value instanceof Float) {
theGenericValue = Float.parseFloat(theTextValue);
}
this.value = (T) theGenericValue;
return this.value;
}
@Override
public void setValue(T value) {
this.value = value;
String theTextValue = value == null ? "" : value.toString();
setText(theTextValue);
}
}And simply use it (along with editor driver) like:
@UiField InputEditor<String> name;
@UiField InputEditor<Float> area;