I want to check the updated value before persisting it. If the check fails, I want to discard the update but that doesn´t work.
EditTextCell cell = new EditTextCell();
Column<AnObject, String> column = new Column<AnObject, String>(cell) +
{ @Override public String getValue(AnObject object)
{ logger.info("getVal:"+object.getId()+", "+object.getAttr());
return object.getAttr();
}
};
column.setFieldUpdater(new FieldUpdater<AnObject, String>()
{ @Override public void update(int index, AnObject object, String value)
{ if (checkValue(value)
{ object.setAttr(value);
databaseUpdate(object);
} else
{ taskDataProvider.refresh(); // to display the original value. Doesn t work
}
}
});
The getValue() method of the column is called and returns the old value, but the new edited value is still displayed. What´s going wrong?
Call clearViewData method in your else statement like this
cell.clearViewData(KEY_PROVIDER.getKey(object));
table.redraw();