1

I have a MenuBar in my VAADIN application, in this MenuBar i have a link to my wiki:

Wiki = new Link();
        Wiki.setCaption("Wiki");
        Wiki.setStyleName("mypicto");
        Wiki.setImmediate(true);
        Wiki.setSizeUndefined();
        Wiki.setIcon(iconWiki);

With a Command:

MenuBar.Command wikiLink = new MenuBar.Command() {

            public void menuSelected(MenuItem selectedItem) {
                getUI().getPage().open("url_to_wiki","_blank");
            }
        };

then i add the link and the commmand in my MenuBar

MenuBar menuBar = new MenuBar();

menuBar.addItem("Wiki",iconWiki, wikiLink);

The problem is, i can't open the link in a new tab, it's only opening in a pop-up, wich is blocked by default in almost all web browsers.

Is there a way to open my link in another tab instead of Pop-up in my MenuBar?

Supamiu
  • 8,501
  • 7
  • 42
  • 76
  • This might help http://stackoverflow.com/questions/24039476/vaadin-open-link-in-new-tab – Kevvvvyp Oct 17 '14 at 09:41
  • If you figure it out, let me know, I had this issue yesterday! – Kevvvvyp Oct 17 '14 at 09:42
  • getUI().getPage().open("url_to_wiki","_blank",false); Doesn't work better (saw it in http://stackoverflow.com/questions/24039476/vaadin-open-link-in-new-tab) – Supamiu Oct 17 '14 at 10:14

1 Answers1

0

I think this may be what you are looking for... https://vaadin.com/directory#addon/activelink

This addon let me open a page in a new tab. I tested it out using this code from the Vaadin 7 Cookbook.

@SuppressWarnings("serial")
public class DemoActiveLink extends UI {

@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = DemoActiveLink.class)
public static class Servlet extends VaadinServlet {
}

@Override
public void init(VaadinRequest request) {
    ActiveLink link = new ActiveLink("Vaadin", new ExternalResource(
            "http://vaadin.com"));
    link.setTargetName("_blank");
    link.addListener(new LinkActivatedListener() {
        public void linkActivated(LinkActivatedEvent event) {
            Notification.show("Link was opened in a new window.");
        }
    });

    setContent(link);
  }
}

&

@SuppressWarnings("serial")
public class DemoButtonLink extends UI {

@Override
public void init(VaadinRequest request) {
    Button button = new Button("Vaadin");
    button.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            getPage().open("http://vaadin.com", "Vaadin");
        }
    });
    button.setStyleName(Reindeer.BUTTON_LINK);
    setContent(button);
}

}
Kevvvvyp
  • 1,704
  • 2
  • 18
  • 38
  • You may or may not need: " @WebServlet(value = "/*", asyncSupported = true) @VaadinServletConfiguration(productionMode = false, ui = DemoActiveLink.class) public static class Servlet extends VaadinServlet { } " This works for my setup. – Kevvvvyp Oct 20 '14 at 10:19
  • I thought it was the solution, but no, i need this to be in a menubar.Command, not in a button or an activeLink – Supamiu Oct 22 '14 at 14:15