Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Close User Session programmatically
Close User Session programmatically [message #758955] Fri, 25 November 2011 11:42 Go to next message
Avrajit Chatterjee is currently offline Avrajit ChatterjeeFriend
Messages: 68
Registered: September 2011
Member
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 #758962 is a reply to message #758955] Fri, 25 November 2011 11:57 Go to previous messageGo to next message
Avrajit Chatterjee is currently offline Avrajit ChatterjeeFriend
Messages: 68
Registered: September 2011
Member
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.
Re: Close User Session programmatically [message #758964 is a reply to message #758955] Fri, 25 November 2011 11:57 Go to previous messageGo to next message
Avrajit Chatterjee is currently offline Avrajit ChatterjeeFriend
Messages: 68
Registered: September 2011
Member
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.
Re: Close User Session programmatically [message #759050 is a reply to message #758964] Fri, 25 November 2011 20:31 Go to previous message
Benjamin Wolff is currently offline Benjamin WolffFriend
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.
Previous Topic:Close User Session programmatically
Next Topic:Keep the old theme from 1.4 in 1.5M3
Goto Forum:
  


Current Time: Thu Mar 28 15:22:28 GMT 2024

Powered by FUDForum. Page generated in 0.03354 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top