redirect to external url in new tab

hi, i have vaadin flow application and in button click i want to redirect the user to another website
how do i do that?

found this but no answer https://vaadin.com/forum/thread/12476014

Use Anchor, see

https://demo.vaadin.com/javadoc/com.vaadin/vaadin-core/10.0.1/com/vaadin/flow/component/html/Anchor.html

If you want page to open in new browser tab, set the target to be “_blank”.

thanks! anchor would be ok for static link, but external url is dynamic (parameters) and need to change that on the fly

See the [Anchor.setHref(…)]
(https://demo.vaadin.com/javadoc/com.vaadin/vaadin-core/10.0.1/com/vaadin/flow/component/html/Anchor.html#setHref-java.lang.String-) method, you can change url with it:

setHref(String href) Sets the URL that this anchor links to.

ok, thanks, I give it a try. does setHref work when clicking the link?

found that this works, but popup is blocked
UI.getCurrent().getPage().executeJavaScript(“window.open(‘https://www.google.com’);”);

Hi,
Why is not possible to add click listener on Anchor? What would be an alternative?
Thank you,
Matic

I want to redirect to external url (/saml/login) without clicking button/Anchor , how to do it in vaadin 10? Please help.

Shankar SG:
I want to redirect to external url (/saml/login) without clicking button/Anchor , how to do it in vaadin 10? Please help.

If use case is to redirect non-logged in users to external SSO login page, then I would do it differently. I would not do redirecting in logout button, but instead implement it in access control of the views using BeforeEnterEvent, you need to implement BeforeEnterObserver interface in the view and override beforeEnter(..) method as follows:

@Override
public void beforeEnter(BeforeEnterEvent event) {
    if (VaadinSession.getCurrent().getAttribute("userLoggedIn") == null) {
        UI.getCurrent().getPage().executeJavaScript("window.open(\"http://vaadin.com/\", \"_self\");");
    }
}

I have implemented SAML protocol to authenticate users in Vaadin 8 application. I have overrided Servlet service method and leveraged HttpServletResponse.sendRedirect to redirect to IDP SSO url. Then, after redirect from IDP to my ACS url, I processed in the service method SAMLResponse from IDP.
Now I am trying to migrate to Vaadin 10 and have a trouble see. https://vaadin.com/forum/thread/17340079/17340080 How to resolve this ?