How to design an application with several "states"(screens)?

For example, I want to implement a login screen, main screen (when logged in), admin mode. How would you go about that? I tried something with windows and the application switching between them, but encountered a problem that I described in
http://dev.vaadin.com/ticket/8043

I wonder, isn’t this switching through windows very common, don’t you need it anywhere where the application has several states? And if this is the case, how can a bug like that still exist? This leads me to thinking that maybe there is something wrong with my code, or this just not the way this is done usually.

Any suggestions are welcome, thank you!

The usual workaround for the window switching bug is to just switch the content (i.e. layout) of the window.

getMainWindow().setContent(newContent);

Thanks for your answer!

You mean this is a known bug? If it is, what is the cause? If we know it, we can work around it.

By switching the content, do you mean that I can have for example 3 layouts and just one main window, and I can switch the content of the window through these layouts, which contain the other components? This may work, but is it a good practice?

Yes, you can switch content of the main window on-the-fly. You can switch out sub-areas within the main window. Not only is this legal, I’ve heard the Vaadin team strongly recommend doing so. They suggest creating tabs or other GUI navigation devices using Vaadin widgets to guide your users to various parts of the app, all living within the single main window.

Remember that when you switch the main window or its sub-areas, the switched out content is still “open” in the sense that it is still instantiated and executing. All your layouts are objects in memory on the server-side. Whether they are shown on-screen to the user is irrelevant to their life-cycle.

While you can open multiple native (browser) windows/tabs, doing so can be problematic. The Vaadin team has talked about improving support for multiple native windows/tabs for Vaadin 7.

–Basil Bourque