Controll the close action on a Popup-Window

Hi,
I need help finding a way, to add some code to the close-event in a popup-Window (Dataset-Edit-Screen).
Normaly, when a data-record ist edited in a popup-mask-window and you change something and then do not save but close, you get a dialog with three options:
Save, Save not, Cancel (in German: Speichern, Nicht Speichern, Abbrechen)
Now the question:
Is there a way, to add some code to the cancel-event ?
There is a method “postCommit()” in the AbstractEditor to override, but I need something like
“postRollback()”.

Thank you!

Auswahl_085|690x461

Hi,

you have the ability to use the setAfterWindowClosedHandler of the actions.

I created an example:

13

on-cancel-editor-example.zip (84.7 KB)

CustomerBrowse

public class CustomerBrowse extends AbstractLookup {

@Named("customersTable.create")
protected CreateAction customersTableCreate;

@Named("customersTable.edit")
protected EditAction customersTableEdit;


@Override
public void init(Map<String, Object> params) {
    super.init(params);

    registerCreateActionCloseListener();
    registerEditActionCloseListener();

}

/**
 * registers a listener to the window closed event of the creation screen
 */
private void registerCreateActionCloseListener() {

    customersTableCreate.setAfterWindowClosedHandler((window, closeActionId) -> {
        if (closeActionId.equals(Editor.WINDOW_CLOSE)) {
            showNotification("The creation was cancelled...");
        }
    });
}

/**
 * registers a listener to the window closed event of the edit screen
 */
private void registerEditActionCloseListener() {

    customersTableEdit.setAfterWindowClosedHandler((window, closeActionId) -> {
        if (closeActionId.equals(Editor.WINDOW_CLOSE)) {
            showNotification("The edit was cancelled...");
        }
    });
}

}

I hope this helps.

Bye
Mario

1 Like

Hi,

thanks very much.