|
|
|
Re: Close User Session programmatically [message #759050 is a reply to message #758964] |
Fri, 25 November 2011 20:31 |
Benjamin Wolff Messages: 136 Registered: July 2009 |
Senior Member |
|
|
Hi,
I have the same use cases in my applications and I use the following mechanism:
1. Let the server session be destroyed ASAP: For this I register a listener in my WorkbenchWindowAdvisor that gets called after the workbench closes:
@Override
public void postWindowClose() {
RWT.getRequest().getSession().setMaxInactiveInterval(10);
}
Important to note here is that I choose 10 seconds to give other RAP mechanisms the chance to shutdown gracefully, since sometimes 1 seconds seems to be too short and a new session will get created or an error is thrown.
2. Close the application browser tab: to achieve this, I register a dispose listener to the Display in the preWindowOpen() method of the WorkbenchWindowAdvisor that executes soem JS code:
Display.getCurrent().disposeExec(new Runnable() {
@Override
public void run() {
String jsCode = "window.location.href='about:blank';" +
"window.open('','_parent','');" +
"window.close();";
JSExecutor.executeJS(jsCode);
}
});
I choose to navigate to a blank page and try to close the window. The window close will work with IE, but not in FF for example. So in FF it will just navigate to an empty page (about:blank) so that the JS gets unloaded for sure and the IE even closes the browser/tab due to the window.close().
This is kind of a hacky solution, but works ;). It should be mentioned that the JSExecutor API is RAP internal and may be subject to change! There is even file an issue in RAP bugzilla for that.
HTH,
Ben
Am 25.11.2011 12:57, schrieb Avrajit:
> I have got answer to my 2nd question. We can get hold of the session and setting the maInactiveInterval to 1 (say) triggers the Ui session closure. But if you set it to 0 nothing happens.
|
|
|
Powered by
FUDForum. Page generated in 0.03158 seconds