-
1. Re: Bus process in onWindowClosing event
jdestef Sep 20, 2013 4:19 PM (in response to jdestef)Hi,
I've answered my own question but I'll post here in cast anyone else runs into a similar problem. At first I thought their might be some Erraii related issue with the bus closing down before the browser window actually closed. On further investigation, async calls happening in the main windows onCloseHandler where executing in FireFox and IE but not in Chrome. The purpose of the call was to log the user out if they were logged in when the window was reloaded, navigated away from, or the browser was closed.
It seems that FireFox and IE does successfully run async calls in the close handler but Chrome does not. There are various bits and pieces of info on the web about this. To address this issue I used a native method that called a jQuery function to send a sync call to a rest service which logged the user out of the back end. It looks something like this:
Window.addCloseHandler(new CloseHandler<Window>() {
@Override
public void onClose(CloseEvent<Window> event) {
if (clientUserToken.isLoggedIn() == true) {
// windowCloseService.call().windowCloseAction();
windowCloseTrapped();
}
}
});
.............
public static native void windowCloseTrapped() /*-{
$wnd.jQuery.ajax({
url : "/olhie/rest/windowclose/closeaction",
async : false,
contentType : "application/json; charset=utf-8",
dataType : "json",
data : ({}),
type : "POST",
success : function() {
return true;
},
error : function() {
alert('Error');
}
});
}-*/;
Hope this might be useful to others with a similar issue.
Thanks