Root.getCurrent() is null / How to access Navigator?

Hello,

I’ve got a root with a Navigator. The first page that is shown is a login form:


public void init(WrappedRequest request) {
		SimpleViewDisplay display = new SimpleViewDisplay();
		setContent(display);

		// Navigator is instance variable with getter
		navigator = new Navigator(Page.getCurrent(), display);

		navigator.addView(LoginMainLayout.VIEW_NAME, LoginMainLayout.class);

		// react to initial fragment, received before we created the Navigator
		navigator.navigateTo(LoginMainLayout.VIEW_NAME);

When I try to get the root within my LoginForm the root is always null:


LoginForm login = new LoginForm();
login.addListener(new LoginForm.LoginListener() {
    public void onLogin(LoginEvent event) {
           ... Root.getCurrent(); //--> null

I want to use the Navigator to navigate to the next page, if the login is succefull. How can I access the Navigator, when I do not get the root?
Or what is the best way to use the Navigator? In my opinion it should be accessibel from all components, shouldn’t it?

I’m using Vaadin Alpha 3.

Thanks.

That sounds like a bug, create a ticket at http://dev.vaadin.com and somebody will have a look at it. The workaround would be to use ((LoginForm) event.getSource()).getRoot();

Edit: Created http://dev.vaadin.com/ticket/9372 and fixed the issue

Perhaps it’s the same reason… but when I submit the form from the LoginForm.LoginListener() then the Root.getCurrent() is also in the next component null. For example here:


public class NavigationContainer extends VerticalLayout {

	public NavigationContainer(final MainContentContainer mainContent) {
		final TestApplication root = (TestApplication) Root.getCurrent(); // --> null