alexanoid
alexanoid

Reputation: 25892

Vaadin 23 open new browser tab with url on Button click

I may open a browser new tab with Anchor component configured with target=_blank. How to do the same in Vaadin23 with the Button component inside the ClickListener code?

Upvotes: 1

Views: 1877

Answers (1)

Tarek Oraby
Tarek Oraby

Reputation: 1219

You can do it using UI.getCurrent().getPage().open(String url), which opens the URL in a new tab by default.

Button button = new Button("Click Me", e -> {
    UI.getCurrent().getPage().open("https://stackoverflow.com");
});
add(button);

Upvotes: 3

Related Questions