What is the replacement for setLogoutURL method in vaadin 8

Viewed 48

Our vaadin 6 application runs in a browser pop up window provided by another web app. However, that web app is not aware of when our application is completed so the responsibility to close the browser pop up is on us. We did that in the vaadin 6 by using setLogoutURL method to redirect to another servlet after vaadin application is closed and run JS command window.close() from that servlet.
I didn't find similar concept of setLogoutURL in vaadin 8. What is the replacement for that in the same scenario? Basically, I am looking for a hook that can run a JS command to close the browser pop up after vaadin UI is properly closed. I am assuming the following code will not work.
myUI.close();
JavaScript.getCurrent().execute("window.close()");
// let this thread go back to vaadin framework here
Because the close() and execute() may be in a race.

2 Answers

In Vaadin 8 the best practice for logout procedure is indeed different. You should invalidate http session via Vaadin session and after use set location with logout url.

vaadinSession.getSession().invalidate();
ui.getPage().setLocation("");

I found that the solution given in Answer 1 is not completely correct. When running the code given in the solution, an internal error occurs. The following code will work, basically not invalidate the session but only setLocation.

ui.getPage().setLocation("page1");
ui.close();

So the replacement of vaadin 6 setLogoutURL() is ui.getPage().setLocation("page1") in vaadin 8.

Related