Vaadin: how to use the navigator from the view?

I am currently watching the Vaadin plugin in Grails, and this is what I am trying to implement:

I have a UI class and two View classes

There is a navigator in the UI code:

 class MyUI extends UI { @Override protected void init(VaadinRequest vaadinRequest) { Navigator navigator = new Navigator(this, this) navigator.addView(MainView.NAME, new MainView()) navigator.addView(CountView.NAME, CountView.class) } } 

There is a Button in MainView, and I want the user to be redirected to the CountView after clicking the button. I added Button.ClickListener() , but I can not get the Navigator instance in the View to go to the desired page.

I would be grateful if you could give me an example of this.

+8
grails vaadin vaadin7
source share
1 answer

you can say

 getUI().getNavigator().navigateTo("foobar"); 

or

 UI.getCurrent().getNavigator().navigateTo("foobar"); 
+22
source share

All Articles