You can restore state, but it's a bit more work than just using GWT
History.  Basically you'll need to come up with some way of modifying
the url search parameter (stuff after the #) to include some info so
that you can bring the user back into the same state as they were
before.   For example, if your application has a number of screens and
they were on screen foo, which was loading with properties for an item
with id 10 then you'd need that information in the Url.

ex:  http://yourApp.com/gwtHostPage.html#screen=foo_id=10

You could also put a conversation id in the url param and then keep
the fine details cached on the server, but that makes the state/data
more transient. If you go with an option like this though it can help
make your pages open and work in other tabs and even make points in
your application bookmark'able'.


Now for the easy answer, yes you can just prevent the user from
carelessly clicking refresh.  Fortunately there isn't a way to trap
somebody on a webpage (think about how bad the web would be).   But,
you can use the WindowCloseListener to present a user with a
confirmation before they close the window, navigate to a new page, or
hit refresh.  It'd look something like this (not tested):

/////////////////////////
Window.addWindowCloseListener(
  new WindowCloseLisener(){

    public String onWindowClosing(){
      return "Are you sure you want to leave this application?";
    }

    public void onWindowClosed(){
        // Cleanup if need be
     }
});
////////////////////////////////




On Mar 13, 2:52 pm, dodo <[email protected]> wrote:
> GWT provides History.onHistoryChange event to handle history but how
> can we restore application state when a user clicks on Refresh button?
> For example the user performed multiple actions on the web site and
> then clicked refresh button. Now how using GWT History class we can
> restore the same state?
>
> Another question, is there a way to trap "Refresh" click before
> actually the app refreshes and can be cancel the event?
>
> Rajesh
--~--~---------~--~----~------------~-------~--~----~
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