Here's the problem:  This is the way you normally popup a confirmation
dialog.

Window.addWindowClosingHandler(new ClosingHandler() {
    @Override
    public void onWindowClosing (ClosingEvent event)
    {
        event.setMessage("Are you sure?";);
    }
});

or prior to 1.6


            Window.addWindowCloseListener(new WindowCloseListener(){

                @Override
                public String onWindowClosing ()
                {
                    return "Are you sure?";
                }

                @Override
                public void onWindowClosed ()
                {
                    // TODO Auto-generated method stub

                }
            });

The problem, if I'm not mistaken (I haven't looked into history in a while),
is that history is done through a hidden iframe, thus when the user hits
back, it's quite possible that the window close event won't get generated
(the browser will simply load the iframe).

Try & see if it works.  If it doesn't, then you'll have to actually extend
the GWT code itself (History.java) to add this feature.  Shouldn't be too
difficult.

On Thu, Apr 2, 2009 at 5:46 PM, Thomas Broyer <[email protected]> wrote:

>
>
> On 2 avr, 17:39, Juzlim <[email protected]> wrote:
> > When the user presses the back button on their browser, I'd like to be
> > able to pop-up a confirmation message. If they cancel, then I'd like
> > them to stay in their current state. What is the easiest way of doing
> > this? In other words, how can you prevent the back button from
> > invoking "onHistoryChanged" upon confirmation?
>
> I'm afraid you just can't.
>
> Though you can eventually keep a global boolean flag and in
> onHistoryChanged, if the flag is true, your pop-up your confirmation
> dialog and newItem to the correct state (note that you'll lose the
> "forward" history).
>
> If I were your, I'd try to reverse-engineer what GMail does for their
> "new message" page, if that's the kind of behavior you'd like to
> achieve (I haven't tried using history while composing a mail in
> GMail, but I suspect it'll just save the changes as draft).
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to