Detect back button

Hi eveybody,

I am encountering a problem with Vaadin.

My Vaadin application connects to a self written application server. A user needs to log in in the webapp. Of course a user can log out. When the users performs a logout, all connections to the applicationserver are closed. After logging out, the user is redirected to our main homepage.

When the user presses the back button in his browser, the browser goes back to the last page from our application. If the user now clicks on something in this screen, a lot of terrible stuff happens because no connections to the application server are available.

Instead of writing a test in every location to check for connections, I want to be able to detect if a window is (re)opened, a kind op Window.OpenListener :wink:

Here I can check my connections and create new ones.

I’m not able to stop the application, because I made my application support multitabbed browsing. The other tabs should remain open en functioning.

Can somebody give me a helping hand ?

Thanks

Sorry, but you’re going to have to check for that state in your app and do the right thing.

There’s no general way to know that the Back button was used. Even if you could in some cases, there would still be X ways to do the same thing, e.g. using a History menu, scrolling the screen to the left in some browsers on some versions of MacOs, using developer tools present in most browsers, etc. On the server side, you have to always assume that the browser is your enemy and will do everything it can to break your app. :slight_smile:

I just finished writing some code to handle a similar case: user clicking Back on a page to which they were forwarded after a form was submitted. The Back button ended up submitting the form data again in this case, so we had to check and do the right thing.

Good luck,
Bobby