Reputation: 711
I have google'd quite a lot but was not able to find a solution for this problem. I have a Vaadin application that runs in a browser window. I have a logout button on it, clicking on it must invalidate the session and close the browser window. I was able to get this code to invalidate the session and close the application. However, I am looking to close the browser window also, which is where I am not having any success
WebApplicationContext webCtx = (WebApplicationContext) appRef.getMainWindow().getApplication().getContext();
HttpSession session = webCtx.getHttpSession();
session.invalidate();
appRef.getMainWindow().getApplication().close();
I am using vaadin 6.x and tried the following but they don't work on browsers I tried which is Chrome and IE.
appRef.getMainWindow().executeJavaScript("window.close();");
Any ideas would be greatly appreciated. Another question I have is do I need to get the name of the main Window and then call mainWindow.close(); or just window.close() ?
Upvotes: 1
Views: 4621
Reputation: 11993
appRef.getMainWindow().getApplication()
to get the Application. Just do appRef.close();
appRef.getMainWindow().executeJavascript("window.close()");
will work as expected.Upvotes: 3