You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-user@incubator.apache.org by Martin Koci <Ma...@aura.cz> on 2006/09/20 15:00:47 UTC

Closing dialog with alt-f4

Hello,

there is commmon problem with web application that we cannot register a
listener to a "closing window" event. 

Have trinidad a solution for this - call a returnListener if user closes
dialog with alt-f4 or with click at cross in right top corner?

Thanks,

Martin





Re: Closing dialog with alt-f4

Posted by Christoph Lassner <Ch...@esg.de>.
Hello Martin,

there is a possibility to control this, because an onUnload JavaScript
action is fired in the dialog window at closing. The way to control such an
action would be to add an onUnload property to your body tag of the pages
in the dialog window that calls a JavaScript function in the parent window.
This function has to check wether the dialog has been closed or only
another page has been loaded and then do the necessary actions.

Sounds difficult, but is very easy. Here's a simple example:


parent.html:
<HTML>
<HEAD>

<TITLE>Controltest</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
var dialog  = null;

function checkIfClosed()
      {
      alert("Checking if child is closed...");
      if(dialog != null)
            {
            alert("Child has been opened!");
            if(dialog.closed == true)
                  {     dialogClosed();   }
            else
                  {     alert("... and not been closed yet!");    }
            }
      else
            {
            alert("Child has never been open!");
            }
      }

function dialogClosed()
      {
      alert("Hey dude, you at least gotta fill out our great dialog!");
      }

function openDialog()
      {
      dialog      = window.open("child1.html", "dialog", "");
      }
//-->
</SCRIPT>

</HEAD>
<BODY>

<A HREF="Javascript: openDialog();">Open Dialog</A>
<A HREF="Javascript: checkIfClosed();">CheckIfClosed</A>

</BODY>
</HTML>


child1.html:
<HTML>
<HEAD>

<TITLE>Child 1</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
function callParent()
      {
      alert("Calling parent...");
      window.opener.checkIfClosed();
      alert("Ready!");
      }

//-->
</SCRIPT>

</HEAD>
<BODY onUnload="window.opener.setTimeout('checkIfClosed();',0);">

<A HREF="child2.html">Goto child 2</A>
<A HREF="Javascript: callParent();">callParent()</A>

</BODY>
</HTML>


and child2.html:
<HTML>
<HEAD>

<TITLE>Child 1</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
function callParent()
      {
      alert("Calling parent...");
      window.opener.checkIfClosed();
      alert("Ready!");
      }

//-->
</SCRIPT>

</HEAD>
<BODY onUnload="window.opener.setTimeout('checkIfClosed();',0);">

<A HREF="child1.html">Goto child 1</A>
<A HREF="Javascript: callParent();">callParent()</A>

</BODY>
</HTML>



The function callParent() in the two childPages is unnecessary and only
there to show how it works (calling the parent window). The
window.opener.setTimeout(...) is necessary, because at a direct call of the
function checkIfClosed() on unloading the child window.closed property
would still return false, so this is a little workaround.

Have fun with these scripts and mail if you encounter problems!
Chris



"Adam Winer" <aw...@gmail.com> schrieb am 20.09.2006 18:59:52:

> No, we don't currently address this;  you get no events
> when this happens.
>
> -- Adam
>
>
> On 9/20/06, Martin Koci <Ma...@aura.cz> wrote:
> >
> > Hello,
> >
> > there is commmon problem with web application that we cannot register a
> > listener to a "closing window" event.
> >
> > Have trinidad a solution for this - call a returnListener if user
closes
> > dialog with alt-f4 or with click at cross in right top corner?
> >
> > Thanks,
> >
> > Martin
> >
> >
> >
> >
> >


Re: Closing dialog with alt-f4

Posted by Adam Winer <aw...@gmail.com>.
No, we don't currently address this;  you get no events
when this happens.

-- Adam


On 9/20/06, Martin Koci <Ma...@aura.cz> wrote:
>
> Hello,
>
> there is commmon problem with web application that we cannot register a
> listener to a "closing window" event.
>
> Have trinidad a solution for this - call a returnListener if user closes
> dialog with alt-f4 or with click at cross in right top corner?
>
> Thanks,
>
> Martin
>
>
>
>
>

Re: Closing dialog with alt-f4

Posted by Martin Koci <Ma...@aura.cz>.
http://issues.apache.org/jira/browse/ADFFACES-191

Adam Winer píše v Čt 21. 09. 2006 v 13:29 -0700:
> Could you file a JIRA issue, and put this sample code in there?
> It'd be great if we delivered a ReturnEvent for this scenario.
> 
> -- Adam
> 
> 
> On 9/21/06, Christoph Lassner <Ch...@esg.de> wrote:
> >
> > Sorry, the code is formatted terribly due to the mail transmission, you've
> > to reformat it to read it... :-) But it's only a few lines.
> >
> > Martin Koci <Ma...@aura.cz> schrieb am 20.09.2006 17:00:47:
> >
> > > Hello,
> > >
> > > there is commmon problem with web application that we cannot register a
> > > listener to a "closing window" event.
> > >
> > > Have trinidad a solution for this - call a returnListener if user closes
> > > dialog with alt-f4 or with click at cross in right top corner?
> > >
> > > Thanks,
> > >
> > > Martin
> > >
> > >
> > >
> > >
> >
> >


Re: Closing dialog with alt-f4

Posted by Adam Winer <aw...@gmail.com>.
Could you file a JIRA issue, and put this sample code in there?
It'd be great if we delivered a ReturnEvent for this scenario.

-- Adam


On 9/21/06, Christoph Lassner <Ch...@esg.de> wrote:
>
> Sorry, the code is formatted terribly due to the mail transmission, you've
> to reformat it to read it... :-) But it's only a few lines.
>
> Martin Koci <Ma...@aura.cz> schrieb am 20.09.2006 17:00:47:
>
> > Hello,
> >
> > there is commmon problem with web application that we cannot register a
> > listener to a "closing window" event.
> >
> > Have trinidad a solution for this - call a returnListener if user closes
> > dialog with alt-f4 or with click at cross in right top corner?
> >
> > Thanks,
> >
> > Martin
> >
> >
> >
> >
>
>

RE: Closing dialog with alt-f4

Posted by Christoph Lassner <Ch...@esg.de>.
Sorry, the code is formatted terribly due to the mail transmission, you've
to reformat it to read it... :-) But it's only a few lines.

Martin Koci <Ma...@aura.cz> schrieb am 20.09.2006 17:00:47:

> Hello,
>
> there is commmon problem with web application that we cannot register a
> listener to a "closing window" event.
>
> Have trinidad a solution for this - call a returnListener if user closes
> dialog with alt-f4 or with click at cross in right top corner?
>
> Thanks,
>
> Martin
>
>
>
>