How to track system generated dialog box/window?

Discussion in 'Java' started by Vasu, Dec 14, 2006.

  1. Vasu

    Vasu Guest

    Hi

    i have a web application that is developed suign struts. When the user
    clicks the 'X' button in the window, i want to move to an action class
    that performs a database update and then has to close the window.

    Kindly help.

    Let me know if theres any issue with teh code below:


    JSP
    -------


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html;
    charset=iso-8859-1">
    <title>Untitled Document</title>
    <script>
    function doUnload(){
    if (window.event.clientX < 0 && window.event.clientY < 0) {
    alert("Window is closing...");
    document.form.action="logout.do";
    }
    }
    </script>
    </head>
    <body onunload="doUnload()">
    <a href="http://www.yahoo.com">Yahoo</a>
    </body>
    </html>

    Struts-config.xml
    -----------------------------

    <action path="/logout"
    type="com.bt.osat.actions.ActionProductStatus"
    scope="session"
    >

    <forward name="success" path="/jsp/logout.jsp"/>
    <forward name="failure" path="/jsp/failure.jsp"/>
    <forward name="Invalid"
    path="/jsp/NoAuthentication.jsp"/>
    <forward name="sessionexpired"
    path="/jsp/sessionexpired.jsp"/>
    </action>


    Thanks in advance.

    Regards,
    Vasu
    Vasu, Dec 14, 2006
    #1
    1. Advertising

  2. Vasu wrote:
    ....
    > Let me know if theres any issue with teh code below:


    Many, starting with..
    ....
    > <body onunload="doUnload()">


    <http://groups.google.com/group/comp.lang.javascript/search?q=onunload&start=0&scoring=d&>

    Andrew T.
    Andrew Thompson, Dec 14, 2006
    #2
    1. Advertising

  3. Vasu

    Vasu Guest

    I anyway found my mistake.

    i had not submitted the form.

    Heres the jsp code:

    <SCRIPT language=javascript>



    function doUnload()
    {
    window.document.forms[0].action="logout.do";
    window.document.forms[0].method="post"
    window.document.forms[0].submit();
    }
    </SCRIPT>
    this works fine for alt+f4 and the 'X' button too.


    Andrew Thompson wrote:
    > Vasu wrote:
    > ...
    > > Let me know if theres any issue with teh code below:

    >
    > Many, starting with..
    > ...
    > > <body onunload="doUnload()">

    >
    > <http://groups.google.com/group/comp.lang.javascript/search?q=onunload&start=0&scoring=d&>
    >
    > Andrew T.
    Vasu, Dec 14, 2006
    #3
  4. Vasu wrote:

    Please refrain from top-posting.

    > I anyway found my mistake.


    The real mistake is depending on 'onunload' to
    be called at all.
    ....
    > this works fine for alt+f4 and the 'X' button too.


    On your browser, on your OS? That is unfortunate for you..

    I would expect clicking the close 'X' button to get rid of
    the UA (browser), and any remaining stray windows.

    Post your 'solution' to comp.lang.javascript, and watch
    them ruin it on a dozen browsers, running on a variety
    of OS's.. ( I dare you ;)

    Andrew T.
    Andrew Thompson, Dec 14, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UGlrb2xvIE1vbmRv?=

    model dialog box keeps refreshing its parent window.

    =?Utf-8?B?UGlrb2xvIE1vbmRv?=, Jun 9, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,967
    Trevor Benedict R
    Jun 9, 2004
  2. Earl Teigrob
    Replies:
    1
    Views:
    5,825
    Earl Teigrob
    Jun 16, 2004
  3. =?Utf-8?B?RWR3YXJkIEY=?=

    How can I invoke the File System Dialog box

    =?Utf-8?B?RWR3YXJkIEY=?=, Apr 25, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    376
    Lucas Tam
    Apr 25, 2005
  4. bienwell
    Replies:
    5
    Views:
    5,185
    bienwell
    Aug 13, 2006
  5. Dica
    Replies:
    8
    Views:
    261
    Jeff Cochran
    Oct 5, 2005
Loading...

Share This Page