A View Manager in Vaadin

One of the problems I faced early on in developing a Vaadin Application was how to move from one screen to the next.

I managed to find a example pattern which is based on a "View Manager". This object is responsible for maintaining the various screens within the application. At any point you can ask the "Manager" for a previous screen and you can display its contents.

The example I found that uses this pattern is called the "Gas Diary".

The View Manager class itself contains a HaspMap and a Stack. The HashMap contains a string for the name of the view and a Layout. The Stack contains a Layout.

In the Gas Diary Main Application the Login Screen is "switched" to via this process.



        setMainWindow(mainWindow);
        
        viewManager = new ViewManager(mainWindow);
        
        // Create the login screen
        viewManager.switchScreen(LoginScreen.class.getName(), new LoginScreen());


This method has worked for me and I suspect it will work for you.

No idea why this isn't documented anywhere in the "official" Vaadin documentation.

Would be nice... 



Comments

Popular posts from this blog

Vaadin - GRID Component

Connecting a Vaadin SQL Container to a Combo Box

Vaadin and Google Maps