Vaadin 7 /ViewManager

I’ve been using an implementation of ViewManager in my applications (v6.8.x). Now that I’m exploring the use of Vaadin 7, I was trying to port at least part of one of those applications, and I’m having problems getting started. As mentioned in another post, the old LoginScreen didn’t work, so I’m building my own login page - no problem. But getting the first screen displayed is causing me trouble.

My original code looked like this:


	@Override
	public void init() {
		Logger.info("myApp starting");
		setTheme("myApp");
		setAppTitle("myApp");
		mainWindow = new Window("myApp");
		mainWindow.setName("myApp");
		setMainWindow(mainWindow);

		// Initialize configuration properties
		initProperties();

		// Initialize the database manager
		dbMgr = new dbManager(this);

		// Initialize the view manager
		viewManager = new ViewManager(mainWindow);

		// Create login screen
		viewManager.switchScreen(LoginScreen.class.getName(), new LoginScreen(this));
	}

Several of those functions appear to have been deprecated. I’m trying it this way but my app starts with a blank screen instead of showing the login page. I’m guessing I’m forgetting something simple in the new startup scheme. Can someone help me jumpstart this? I figure once I get going, I should be ok… I hope :slight_smile:


@Override
	public void init(VaadinRequest request) {
		Logger.info("myApp starting");
//		setTheme("myApp");
		setAppTitle("myApp");
		mainWindow = new Window("myApp");
//		mainWindow.setName("myApp");
//		setMainWindow(mainWindow);

		// Initialize configuration properties
		initProperties();

		// Initialize the database manager
		dbMgr = new dbManager(this);

		// Initialize the view manager
		viewManager = new ViewManager(mainWindow);

		// Create login screen
		viewManager.switchScreen(LoginScreen.class.getName(), new LoginScreen(this));

	}

You should not use mainWindow any more with Vaadin 7 (unless you’re using LegacyApplication, but then you should also use LegacyWindow instead of Window).

Your updated code looks like a UI init method which means that you shouldn’t create and use mainWindow for anything. I guess the problem is that your ViewManager adds the login form components to the mainWindow instead of adding them to the UI?

To fix this, you could try changing the ViewManager constructor to take a UI instance instead of a Window instance - most relevant methods that were declared in Window are also available in UI.