How to open a window as Tab from a sub window ?

Hi,
I mean, I want to create a button on a sub window and if I click it, it can open a new external window. How Can I do?

I tried

“getMainWindow().executeJavaScript(“window.open(‘http://www.google.com/’, ‘_blank’)”);” It shows sub-window cannot execute JavaScript
and
“getMainWindow().open(new ExternalResource(LinkButton.this.url), “_blank”);”
also not work.

What should I do?

Thank you very much!

Hi Xiao,

Are you try to open getting the application instance?, i.e. doing something like:

getApplication().getMainWindow().open(new ExternalResource(LinkButton.this.url), "_blank");

Hope this helps.

Javi

Thank you Javier,
It does not work. In this way I can open a new window but it is a blank window. I do give it the URL…

In FF, it just open a blank page; in IE, it shows
http://localhost:8080/xxxx/VAADIN/widgetsets/com.xxx.ui.widgetset.ZipgroceryWidgetset/www.google.com and cannot open the page

Hi Xiao,

I think I don’t understand your initial question. If you’re trying to open a new window using a Link component, the way to do this should be doing something like this:


    // Link creation
    Link link = new Link("Google", new ExternalResource("http://www.google.com/"));
    link.setTargetName("_blank");
    // Add link to your layout

Hope this helps.

Javi.