I'm in a similar predicament, perhaps you might have an idea of what
to do.

When the user closes the browser window, I want the application to
logout his/her session automatically so as to free up memory on the
server from their session. So I use the onWindowClosed() function to
take care of this... But when the page is refreshed, the session gets
logged out as well through the same function. This is something I want
to stop from happening. Any suggestions?

On Mar 15, 9:26 am, Rohit <[email protected]> wrote:
> Hi
> There is no way in GWT to distinguish betweenRefreshbuttonclick and
> Window closebuttonclick. But you can trackrefreshbuttonwith a
> little trick. You should use a time cookie which will expire after
> some time. So whenrefreshbuttonis pressed, in on module load of
> entry point , track the value of this cokkie, if this cookie is still
> alive, this meansrefreshbuttonis pressed. The time this cookie will
> expired should be considered. It should be very little.
>
> Second for history, you should save your information in Session on
> window close and then ifrefreshbuttonis pressed, get your
> information from this session.
>
> Thanks and regards
>
> Rohit
>
> On Mar 14, 2:30 am, "levi.bracken" <[email protected]> wrote:
>
> > 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 userbackinto 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 clickingrefresh.  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
> > hitrefresh.  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 onRefreshbutton?
> > > For example the user performed multiple actions on the web site and
> > > then clickedrefreshbutton. 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- Hide quoted text -
>
> > - Show quoted text -

--~--~---------~--~----~------------~-------~--~----~
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