postCommit v7 equivalent or onPostCommit close window check

Is there a CUBA7 equivalent for postCommit, where I can check if the window was closed or not?

In 6.x I could do this:

@Override
protected boolean postCommit(boolean committed, boolean close) {
	if (!close && committed) {
		// do something
	}
	return super.postCommit(committed, close);
}

How do I check in 7.x if the user closed the editor or not?:

@Subscribe(target = Target.DATA_CONTEXT)
private void onPostCommit(DataContext.PostCommitEvent event) {
	//Only do this if the window is not closed..?
}

I want to reload the screen data, because some processing is done in the middleware after saving and it’s not reflecting all the changes automatically to the user.
Using the Instanceloader.load() fixes that, but it doesn’t make sense to call it if the window is closed.

You can just override the commit() method of StandardEditor:

@Override
protected void commit(Action.ActionPerformedEvent event) {
    super.commit(event);
    // your logic here
    // called only when committed without closing
}
1 Like

It can be improved:

@Override
protected void commit(Action.ActionPerformedEvent event) {
    // commit changes may return fail() if validation failed
    commitChanges()
        .then({
            // your logic here
            // called only when committed successfully without closing
        });
}
1 Like

Thanks. Both work.
Yuriy solution has a small syntax error (Runnable)

@Override
protected void commit(Action.ActionPerformedEvent event) {
	super.commit(event);
	commitChanges()
			.then(() -> { //correct syntax () ->
				// called only when committed successfully without closing the window			
			});
}