Modal for save confirmation after grid buffer mode save

We are using a grid to present some data. This grid is not using a data provider but setting its items.

We are working on buffered modd, but we still want to show a modal informing what are we about to save, with the posibility to save or cancel.

SaveEditor method has been removed from grid class in our current version (8.4.0), so cant do it that way.

I have come to a close solution but with some remaining problems. I have extended grid component to be able to create my own editor:

public class MyGridComponent extends Grid<MyData> {

public MyGridComponent (Class<MyData> beanType) {
    super(beanType);
}

@Override
protected Editor<MyData> createEditor() {
    return new MyGridEditor(this.getPropertySet());
}
}

On my editor I have overriden following methods:

@Override
protected void doEdit(OutcomeWagerLimit bean) {
    copyMyBean = bean;
    super.doEdit(bean);
}

@Override
public boolean save() {
    String desc = copyMyBean.getDescription();

    StringBuilder captionBuilder = new StringBuilder()
            .append("Save ")
            .append(desc)
            .append("?");
    StringBuilder messageBuilder = new StringBuilder()
            .append("Do you really want to save ")
            .append(desc)
            .append("?");

    openConfirmMsgBox(captionBuilder.toString(), messageBuilder.toString(),() -> super.save(), ()->super.cancel());
    return true;
}

With this code clicking on save opens my confirmation modal. If clicking on save, everything works flawlessly, but clicking on my modal cancel which will call to EditorImpl.cancel() method, acts in a weird way. Clicking cancel on my modal will close edition mode, but if I edit again any other row (double clicking on it) grid’s save and cancel buttons (not the modal ones) stop working. Not launching any request from client to vaadin’s servlet.

Does anyone know any possible solution to this or a better way to reach what I’m trying to achieve?

Thanks in advance

Morning,

Just managed to do it. Since not using dataprovider but normal list, I am the one responsible of saving data in other saveEventListener. That is the moment to present modal and in the “ok” case persist it in database.

So there is no need to override EditorImpl save method and do it in a saveEventListener.

Thanks