I’m new to the whole java/vaadin world and currently i am developing a small app to get into this ‘new world’.
My whole app is just one ‘main’ window and it works quite fine, standalone.
Then I wanted to precede it with a login screen, where a ClickListener on the [Login]
Button should rebuild the MainWindow with the main app.
=> Button and the Listener work, the MainWindow is rebuilt with my main app, but i only see it for the fraction of a second before control jumps back to the login screen.
I tried removing the MainWindow just before rebuilding it with the main app; but the problem stays the same.
Why is it that my main app works ok when i call it directly from init(), but vanishes right after rebuild when it’s called from the ClickListener ?
Is it something fundamental about java and window control that i don’t get ?
You shouldn’t recreate the main window. Instead, you should rebuild its root layout, which you can set with setContent().
Well, you could either empty it and then rebuild it, or replace it with a new root layout.
A common pattern is to use a View Manager, which handles switching between views/screens, such as a login screen and the main screen. Here’s some examples:
There’s another implementation of a view manager (called ViewHandler) in
AppFoundation add-on, which offers also many other features that you need in most applications.