PS2-Calling an ActionListener on browser window close using JS eventQueuing
Hi ,
I need to call an Action Listener(to do some post processing) when a browser window is closed.
To achieve this I am using the ADF Javascript APIs.
I tried the following but neither worked :(
1)Having the following JS code directly in my jspx page -
<af:resource type="javascript">
window.onunload = function(evt){
var button=AdfPage.PAGE.findComponentByAbsoluteId("button"); /** Getting the Abs Id of a button which has the needed ActionListener attached to it */
AdfActionEvent.queue(button,true);
};
</af:resource>
2)Have a clientListener under the af:Document with type as "load" which calls a JS method as below
<af:resource type="javascript">
function onLoad(evt){
window.onunload = function(evt){
var button=AdfPage.PAGE.findComponentByAbsoluteId("button");
evt.cancel(); /* trying to make sure that this doesnot get propagated to the server*/
AdfActionEvent.queue(button,true);
}
};
</af:resource>
3) Having a clientListener call a JS method which queues a Server Listener to call a Action Listener.
window.onunload = function (event){
var source = event.getSource();
AdfCustomEvent.queue(source,"serverListenerMethod",{},false);
}
Also client attribute for the "button" is true.
I am making sure the code is put under metaContainer tag of the af:document
Thanks