Hello Vaadiners,
I have a class that extends a table and another class that extends a form.
Both are added to the same layout and the table is connected to my datasource.
When I select a row on the table, the form gets populated with its contents:
public void valueChange(Property.ValueChangeEvent event) {
Property property = event.getProperty();
if (property == table) {
Item item = table.getItem(table.getValue());
if (item != form.getItemDataSource()) {
form.setItemDataSource(item);
form.setReadOnly(true);
}
}
}
So, when I change an attribute on the form the table is updated automatically.
But I need to update the datasource only after a button “Save” gets clicked:
public void buttonClick(ClickEvent event) {
final Button source = event.getButton();
if (source == editButton) {
setReadOnly(false);
}
else if (source == cancelButton) {
setReadOnly(true);
discard();
}
else if (source == saveButton) {
logger.debug("isModified(): " + isModified());
setReadOnly(true);
try {
commit();
} catch (InvalidValueException invException) {
logger.error("Trade contains invalid values: " + invException.getMessage());
} catch (SourceException srcException) {
logger.error("Error committing changes to trade: " + srcException.getMessage());
}
}
}
To achieve this i used form.setWriteThrough(false).
:what: The problem is that modifications in the form are not being passed to the table.
Is this approach correct? What should I do in order to update data on the table?
Thanks in advance,
Diogo