There must be two handlers: one Window.ClosingHandler and one CloseHandler . See below. This will make sure that the Cancel button is clicked in the dialog box, that CloseHandler does not start. But if you click "ok", CloseHandler executes and runs the necessary code. This can be used to release db locks, gently close open sessions, etc.
Window.addWindowClosingHandler(new Window.ClosingHandler() { @Override public void onWindowClosing(ClosingEvent event) { event.setMessage("You sure?"); } }); Window.addCloseHandler(new CloseHandler<Window>() { @Override public void onClose(CloseEvent<Window> event) {
stuff22
source share