Multi-window/tabs and retrieving previous instances

In Vaadin 7, if I hit a url in 2 different tabs, I will get 2 different instances which is great. These instances have a UI id associated with them and I can find the UIs. Is there a way for me to load the previous instance? I am thinking of using the UI id as a request parameter since those look to be unique. If the init finds the parameter, it can try to find the UI requested but now I need to display it. How would I go about doing that?

Here is a sample of some code in my init.


		String fragment = getPage().getUriFragment();

		if (fragment != null) {
			System.out.println("fragment:" +fragment);
			UI foundUI = VaadinSession.getCurrent().getUIById(Integer.parseInt(fragment));

			if (foundUI != null) {
				// found the ui but now how do we set or navigate to it?
				//UI.setCurrent(foundUI);
				// or
				//UI.getCurrent().setContent(foundUI.getContent()):
			}

		}

You could recreate the content of the one UI in the another via its URIFragment …

But what you are trying to do in your pseudo code is not going to work, and it wil get even worse if you ever use CDI with UIScoped components etc.


UI.getCurrent().getNavigator().navigateto(foundUI.getPage().getLocation().getRawFragment());

Assuming the fragment contains all your state …

But you should not try to move components from one UI to another.