I have the following piece of code that I wrote using Vaadin. The code opens the page www.google.com
when the user clicks the button.
My question is is there any way for me to specify that the page is to be opened in a new tab?
Thanks.
button.addClickListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
getUI().getPage().setLocation("http://www.google.com");
}
});
redirecting can be done with UI. getCurrent(). navigate("") session context can be controlled as explained on https://vaadin.com/docs/v8/framework/articles/SettingAndReadingSessionAttributes.html.
If you want page to open in new browser tab, set the target to be "_blank". See the Anchor. setHref(..)
Vaadin Fusion: StatelessBy default, Fusion will not create server sessions and will use the token-based authentication mechanism, keeping the server stateless. Since server endpoints don't use a session, a server can handle more concurrent users, enabling easier horizontal scaling and high availability of services.
getUI().getPage().open("http://www.google.com", "_blank");
The _blank
window name is important here. Beware that you may also have browsers that will might open the resource in a new window instead.
There is also another signature to the open()
method, i.e.
open(String url, String windowName, boolean tryToOpenAsPopup)
that may fit the bill. HTH.
References: Page (Vaadin 7.2.1 API).
Try the following code:
BrowserWindowOpener opener = new BrowserWindowOpener(new ExternalResource(url));
opener.setFeatures("");
opener.extend(button);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With