Vaadin 8 display custom page, when user hits back button.

Hi all,

when user clicks on back button in browser, hes redirected to previous page in vaadin (if any, im using Vaadins Navigator and Spring-vaadin plugin with SpringViewProvider).
Is there a possibility to implement something like a redirector to an error page or page expired ?


You could implement an NavigationStateManager and add it to your Navigator class (via constructor).

In Vaadin 7.x a Navigator.UriFragmentManager (default implementation of NavigationStateManager) contained a method uriFragmentChanged(UriFragmentChangedEvent event), which could be overwritten.

In Vaadin 8.x you have to copy the implementation of Navigator.UriFragmentManager to your own implementation class in order to add an custom UriFragmentChangedListener (Deprecated). Java Doc directs to com.vaadin.server.Page.PopStateListener which should be used instead (I haven’t tested this yet).
UPDATE: PopStateListener works and is the preferred way