Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vaadin: how do I use Navigator from a View?

I'm looking at Vaadin plugin in Grails at the moment and this is what I'm trying to implement:

I have an UI class and two View classes

The UI code has a navigator in it:

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)

    }
}

In the MainView there is a Button and I want the user to be redirected to CountView after the button is clicked. I added the Button.ClickListener(), but I can't get hold of the Navigator instance in the View to navigate to the desired page.

I'd be grateful if you could provide me an example of this.

like image 936
svz Avatar asked Apr 13 '13 14:04

svz


1 Answers

You can say

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

or

UI.getCurrent().getNavigator().navigateTo("foobar");
like image 112
Henri Kerola Avatar answered Oct 16 '22 09:10

Henri Kerola