Close User Session programmatically [message #758955] |
Fri, 25 November 2011 06:42  |
Eclipse User |
|
|
|
Hi,
We have an Exit button in our RCP application which closes the workbench and disposes the Display object eventually which closes the application. But in RAP it does not close the browser or tab ,it only wipes off the UI elements shown.It does not even trigger the Session close and hence the UI Thread ,SessionStore etc are active till the timeout of maxInactiveInterval.
My questions are
1. Cant we trigger a browser or tab close on Workbench or Display close?
2. Cant we programmatically trigger Session close? I tried to get hold of the session object and reset the maxInactiveInterval but it doesnt seem to work.
Any pointers?
|
|
|
|
|
Re: Close User Session programmatically [message #759050 is a reply to message #758964] |
Fri, 25 November 2011 15:31  |
Eclipse User |
|
|
|
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.03334 seconds