Editable Grid...

Hi,
I am new to Vaadin, so perhaps I miss something very basic here.
I have a Grid which is editable (and buffered); when somebody changes the value, the change must be performed using a backendservice.
For now, I used the “addSaveListener” and try to persist the changes to a backendservice. When an exception occurs, I can notify the user, but the change is still reflected in the Grid. I would like to cancel the change (because the save did not succeed)
What I don’t understand is, how do you “cancel” the change if the backendservice would fail for whatever reason?

I think you have started right way, i.e. using addSaveListener and using onEditorSave(…) there. When you commit data, you should do that e.g. within try - catch clause, and in catch part (i.e there was exception in database commit), re-read the entity from the database, and update that to Grid’s data provider item, since you are updating the bean refreshItem() call in data provider should be enough to update. This will ensure that your data in Grid is consistent with the database.

Ok, I understand, but then I would have to query the database again; is there a way of “cancelling” the change instead of reloading from database? (imagine the “save to database” failed because the database is unreachable (or something), then the reload will fail as well) I was wondering if the entire “edit” could be cancelled?
For those interested, here is a code snippet:

  [size=2]
grid = new Grid<>();
  Binder<SimCard> binder = grid.getEditor().getBinder(); 
  Binder.Binding<SimCard, String> bindingNumber = binder
   .forField(new TextField())
   .bind(SimCard::getNumber, SimCard::setNumber);
  grid.addColumn(SimCard::getId).setCaption("id").setHidden(true);
  grid.addColumn(SimCard::getNumber).setCaption("Number").setEditorBinding(bindingNumber);
  grid.getEditor().setEnabled(true);
  grid.getEditor().addSaveListener(event -> {
    try { SimCardService.save(event.getBean()); }
    catch (PlatformException pex) {
      // => we can cancel the "change" here somehow? Is the old value of the bean stored somewhere?
      Notification.show("Save failed", Notification.Type.ERROR_MESSAGE);
    }
  });
[/size]