Tabbed Browsing : Again(!)

Hello,

We’re designing another project with Vaadin; I’m looking to try and support multi-tab browsing.

I’ve looked at both Joonas’s Navigator, and John Rizzo’s Navigator7 frameworks/plugins.
Both have things I wish to build on, but my chief issue at the moment is supporting multiple tabs. I have been using the URI Fragment component to switch views quite succesfully.

I’d like to be able to support links within my application, whereby left-clicking the link loads the linked-to-view into the current browser window/tab, and right-clicking the link via the standard browser context menu allows the user to open a new tab/window. This would also allow urls to be used in email/im messages, to allow users to navigate to the portions of the application.

As far as I can see, because the URL includes the window name, this currently leads to Communication Errors and so on (two tabs, pointing to the same Vaadin window instance : disaster).

Is it possible to support this usecase in Vaadin as it stands currently? If so how - and if not, might this issue be covered in the Vaadin7 design?

e.g. I’d link to support a link that looks like http://server/application#ViewName/parameters, that if simply clicked in the current window, simply loads the view into the current window, but that the same URL could be entered into a new browser window and create a new Vaadin window insance.

Failing that, an (unpleasant) possible alternative would be to provide two separate links : one to open in the current window, and one in a new browser window/tab. How would I go about that?

Cheers,

Charles.

The simple solution right now at least is not to use the window name in the url. This is how Directory, Sampler and others work if I remember correctly. The only problem is that the windows cannot be tracked properly and thus a refresh of the window will create a new window (which is typically not a problem if the fragment describes what view should be shown).

Try shift-clicking on a Sampler icon on the main page and it will open in a new window, which is independent of the other.

Thanks Artur!

For anyone looking to do the same thing, you do this by overriding Application#getWindow(String), and creating the window if it doesn’t exist. The key thing is not to call the open method on the window instance, as shown by the example in the javadoc.

In short, it’s very simple


class MyApplication extends Application {
  
 [...]


  @Override
  public Window getWindow(String name) {

    Window window = super.getWindow(name);
    if (window != null) {
      return window;
    }

    // Obviously, you'll need to implement the createNewWindow() method to actually create the window
    window = createNewWindow();
    window.setName(name);
    addWindow(window);

    return window;
  }

}

I have also tried to solve tabbed browsing problems. I just got my solution working. So if you still have problems, look how I solved the problem:

http://vaadin.com/forum/-/message_boards/message/272924