Hi,

I am aware of native (JSNI) approach doing this. Involves attaching
unload listener to window. This triggers both on refresh or "hard"
navigation to different url.

public final class MyRefreshListener {

    public static void onUnload() {
        detachOnUnloadListener();
        // Do your stuff here
    }

    private static native void attachOnUnloadListener() /*-{
         $wnd.onunload = function() {
             @com.acme.gwt.client.impl.MyRefreshListener::onUnload()
();
         }
    }-*/;

    private static native void detachOnUnloadListener() /*-{
         $wnd.onunload = null
    }-*/;

}

It could be that on newer GWT version this approach is encapsulated,
but I simply failed to find one.

Hope this helps.

Dmitry

On Feb 16, 6:13 am, Niraj Salot <[email protected]> wrote:
> Hi All,
>
> I would like to have below mentioned functionality in my application.
>
> =========
>
> Once the user is logged in , If by mistake user presses the F5 OR
> refresh button , he should stay on the same page. Right now he is
> redirected to login page and all his session data are lost.
>
> I know about below mentioned functionality
>
> Window.addWindowClosingHandler(new Window.ClosingHandler() {
>                         @Override
>                         public void onWindowClosing(ClosingEvent event) {
>                         }
>
>             });
>             Window.addCloseHandler(new CloseHandler<Window>() {
>
>                         @Override
>                         public void onClose(CloseEvent<Window> event) {
>                         }
>             });
>
> I would not like to warn the user on this situation by writing
> event.setMessage() in onWindowClosing() method. I just want to make
> functionality which will feel the user that nothing has happended even
> if by mistake he done browser refresh.
>
> Let me know how I can do this
>
> Thanks in Advance , Niraj Salot.

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