Vaadin Navigator

Hello
I have a vaadin application with views in it and i have to navigate from one view to another. I am initaializing the view in the UI class and adding all the views. Now to use that navigator in the views can i create a new navigator variable in the views and initialize it from the enter method using event.getNavigator(). Is this the right way to do it or is there any other way.
Asking this since it might make the view class stateful,It has to preserve the variable across requests.

Thank you

Hi,

The UI class has the methods setNavigator and getNavigator, which you can use to store and access your Navigator instance. You can get the current UI with the static UI.getCurrent() accessor.

Best regards,

Olli

The first argument in Navigator’s constructor defines the UI for Navigator and Navigator registers itself for the UI by calling ui.setNavigator(this). So no need to call ui.setNavigator expiclitly.

Navigator can be accessed from UI by calling ui.getNavigator(), and components have getUI(), which means that when a component is attached to a UI, the following works:

myComponent.getUI().getNavigator().navigateTo("foo"); Or

UI.getCurrent().getNavigator().navigateTo("foo");

-Henri

Hi

I want to know if Vaadin preserves the variable values across the requests, if it is stateful or stateless.

Thank You