Hi,
I have an editable table like
container = new BeanItemContainer<MyClass>(MyClass.class);
table = new Table();
table.setContainerDataSource(container); //
table.setEditable(true);
table.setTableFieldFactory(new FieldFactory());
the field factory assigns data source to the fields like this:
private class FieldFactory implements TableFieldFactory {
@Override
public Field createField(Container container, Object itemId, Object propertyId, Component uiContext) {
final Property property = container.getItem(itemId).getItemProperty(propertyId);
TextField field = new TextField(new Property() {
@Override
public Object getValue() {
System.out.println("getValue");
return property.getValue();
}
@Override
public void setValue(Object newValue) throws ReadOnlyException, ConversionException {
System.out.println("setValue");
property.setValue(newValue);
}
@Override
public Class<?> getType() {
System.out.println("getTypes");
return property.getType();
}
@Override
public boolean isReadOnly() {
return property.isReadOnly();
}
@Override
public void setReadOnly(boolean newStatus) {
property.setReadOnly(newStatus);
}
});
field.setImmediate(true);
return field;
}
}
Now when field value changes because of user input I can see bean’s value assigned directly through
MethodProperty
class rather than the one assigned manually (the inner class above). Somehow the dataSource get reset between field creation and handling the value change.
I need some custom parsing of the value hence the need for custom dataSource (a formatter essentially).
Vaading version 6.7.1