Window.addcloseHandler and Window.addwindowClosingHandler does not allocate between browser close and browser refresh event

I am using GWT and in my application I want to clear my session history and force logout in a closing browser. But when the refresh button is clicked, the user must be logged in. For this I wrote the following code.

Window.addCloseHandler(new CloseHandler<Window>() {
    @Override
    public void onClose(CloseEvent<Window> event) {
        logoutRPC();
    }
});

Window.addWindowClosingHandler(new Window.ClosingHandler() {
    public void onWindowClosing(Window.ClosingEvent closingEvent) {
        logoutRPC();
    }
});

      

But from both of the above, I cannot achieve functionality as update calls GWT.closeHandler()

.

How can I distinguish between both events?

+3


source to share


1 answer


There is no way to distinguish between refreshing and closing the browser window on the client side.

Essentially your GWT application is running in the browser window area. If it refreshes, the instance of your application is deleted, the browser loads the url and then creates a new instance.



You can see this when debugging, and your applications GWT onModuleLoad () function is called again on a new instance of your application class.

0


source







All Articles