Proper way to move from one window to another

I am able to create a LoginWindow and from my main application class, set the mainWindow as my “login window”, i want to after authenticating the user redirect to a new window (HomeWindow) — This window creates a ‘HomeForm’ and sets it content, i have tried this

HomeWindow window = new HomeWindow();

***This does not work and gives me a NullPointerException, any ideas

In Vaadin applications have only one main window.
When you want to change what is displayed to the user, you actually change the content of the window.

So what you are tying to do should be :

  • Window myWindow = new MyWindow();
  • myWindow.setContent(loginPageContent);
  • application.setMainWindow(myWindow);

And after user logged in :

  • myWindow.setContent(firstPageContent); //your HomeForm for instance

When designing a Vaadin application you don’t need to think that the whole page will be replaced every time the user do something (like it is for html), if you want to keep header , footer, menu, … and just change the actual content, you can do it easily with Vaadin.

You may also want to look at the Navigator7 and appfoundation addons. I don’t use them myself but they seem to make all the view change handling easier for quite a lot of things.

Thank you for the explanation and quick sample code.