How to change current browser window's location or more precisely switch UI

Hello everyone,

I’m new to here and to Vaadin 7. I have a, for me, very tricky question regarding the way to change current browser window’s location.

Considering the following scenario:


Button clickMe = new Button("Click Me!");
clickMe.addClickListener(new ClickListener() {
  @Override
  public void buttonClick(ClickEvent event) {
    // do some preliminary checks here
    if (...) {
      // load URL_1
    } else {
      // load URL_2
    }
  }
});

What i’m trying to do here is to load some URLs in the current browser window when user clicked on a button. The
com.vaadin.navigator.Navigator
doesn’t help here because the content to load are not views. And obviously I can’t use
com.vaadin.ui.Link
neither because I need to do some checks before to decide what to load. And also, it seems the
com.vaadin.server.BrowserWindowOpener
won’t help as it supports only popup windows. So what can I do else?

This was the first part of my question… :slight_smile:

The second part, now let’s consider that I’m actually going to load a different Vaadin UI within the same application (always in the current browser window). Is there a more appropriate way to do this? Instead of changing the browser window’s location?

Any help would be appreciated.
Thx.
Fang

Use Page.setLocation(“myurl”) :slight_smile: You can get a Page instance either via the UI’s getPage() method, or the static method Page.getCurrent(). As for your second question, changing the location is currently the most appropriate (and pretty much the only) way.

It works great, odd that I didn’t see that method… Anyway thanks a lot Johannes!