View Full Version : Warning of changes when closing a window

30 Nov 2011, 1:38 AM
I have and object that extends a window and when the x is pressed (i.e. window closing) I want to check if change have been made and check if the user is happy to discard the changes.

I have added a window listener and if the beforeHide event fires I check for changes.

If changes have been made I have the following code

new Listener<MessageBoxEvent>(){
public void handleEvent(MessageBoxEvent be) {
if (be.getButtonClicked().getItemId().equals(Dialog.YES)) {
// close the window
System.out.println("In handler");

the problem is that the window closes and then pops up the message box, therefore making it impossible to stop the window from closing if the changes need to be saved.

How do I stop the window from processing the hide long enough for me to check if the user wants to continue

1 Dec 2011, 2:14 AM
I use a closing handler on the (GWT !) window. Something like this :

Window.addWindowClosingHandler(new Window.ClosingHandler() {
public void onWindowClosing(ClosingEvent event) {
if (... unsaved changes in your application ...) {
event.setMessage("... msg to the user ...");

6 Dec 2011, 8:22 AM
I don't seem to have that handler available, I am using version 2 of Ext GWT is it still available.