Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

PS2-Calling an ActionListener on browser window close using JS eventQueuing

Sudipto DesmukhJun 10 2011 — edited Jun 23 2011
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 13 2011
Added on Jun 10 2011
12 comments
3,393 views