Issue with Vaadin sub-window


I have been using Vaadin for sometime. It is an innovative framework. However, I have got some problem with Vaadin sub-windows. To be able to access Vaadin application from multiple tabs of the same browser, I overrode getWindow() method of Application class as following:

	public Window getWindow(String name) {
		Window win = super.getWindow(name);
		if(win == null) {
			win = new Window("New window...");
		return win;

Let say I opened a tab and accessed the application. At this moment, Vaadin’s Application.init() gets executed and it sets the main window for the application as following:

	public void init() {
		final Window main = getWindow();

A window with name “1” gets created. If another tab is opened and the application is accessed then Application.getWindow() is called and a window with name “1_1” gets created. Let say, two sub-windows are opened are opened in the tab with window “1_1”. If I refresh this tab it will maintain its state and both windows are displayed. However, if I go to the first tab with window “1”, refresh it, navigate back to the tab with window “1_1” and refresh it then the state of the tab with window “1_1” is lost.

How do I maintain state of each tab of the browser?

Any help would be greatly appreciated.


Those are actually “application-level windows”, not “sub-windows”, which are just floating HTML frames within the application-level windows.

You are missing the “open” in the getWindow().

    if (window == null) {
        window = new Window("New Window");
        addWindow(window); ExternalResource(window.getURL()));

It makes a redirect in the same browser window/tab to the proper URL (for example /myapp/1_1) for the window. Without the proper URL, if you refresh the page (tab), it doesn’t know which Window object should be associated with the particular browser window, so it creates a yet another new Window instance. The issue is discussed
and at least in
this thread

this example
, which describes the multi-window support for the Book Examples application. Also Sampler uses the same solution.

Thanks for detail explanation and links. I noticed that the demo application loads the application twice. e.g. If I enter url as http://host:port/example, the page is loaded and then it is redirected to http://host:port/example/1_1.
I understand the reason for redirect but is there any way (say by using AJAX and HTML 5 history API) to avoid redirect?


Yes, I would think so, manipulating the location with the HTML 5 history API could work.

Related ticket: