eparamo
(Eduardo Paramo)
#1
Hi, Id like to avoid seeing this screen on an standard editor.

In one screen I already have it as read only the other one I just dont want it to appear. How can I avoid seeing this screen?
I cant put closeWithDiscard() on the the little X button since its the cuba tab close button.
Thank you for the constant help!
gorelov
(Gleb Gorelov)
#2
Hi,
There are several ways to achieve this:
- Override the
hasUnsavedChanges
method in the editor screen:
@Override
public boolean hasUnsavedChanges() {
return false;
}
- Override the
preventUnsavedChanges
method in the editor screen:
@Override
protected void preventUnsavedChanges(BeforeCloseEvent event) {
// do nothing
}
- Use custom Close Action in the editor screen that will not check for unsaved changes:
public class ProductEdit extends StandardEditor<Product> {
private final CloseAction CUSTOM_WINDOW_CLOSE_ACTION
= new StandardCloseAction(Window.CLOSE_ACTION_ID, false);
@Override
protected void cancel(Action.ActionPerformedEvent event) {
close(commitActionPerformed ?
WINDOW_COMMIT_AND_CLOSE_ACTION : CUSTOM_WINDOW_CLOSE_ACTION);
}
}
Regards,
Gleb
4 Likes