Struts and onunload event handler incompatible?

Discussion in 'Java' started by David Orr, Feb 17, 2004.

  1. David Orr

    David Orr Guest

    I am running a Struts 1.1 application using JDeveloper and it's
    embedded OC4J.

    I am having a problem with a .jsp that contains an onunload event
    handler. The page in question is a search results page. Each result
    has a link to preview that result. The preview is shown in a new
    window using a struts action.

    When one of these links is clicked, the window opens and the contents
    are rendered without any problem. Clicking on another similar link in
    the original window will repopulate the popup window. Or the Next and
    Previous links for the search results on the original page will take
    you to the next or previous pages of the results.

    This all works fine until I close the secondary window. If I then
    click on any link in the original search results window, the action
    called by Struts does not get the original session. It appears to be a
    new one as all of the data stored in the old session is gone and only
    a form object for the new page is in this one.

    The strange thing is that if I remove the onunload event handler from
    the body tag on search results page, the problem goes away and
    everything works just fine. Stranger yet, the event handler doesn't
    even have to get called for the problem to occur as clicking on the
    preview links doesn't alter the original results page. I even have
    tried this with an empty event handler. It seems to be the mere fact
    that the onunload event handler is defined.

    I will include what I think are pertinent pieces of the configuration
    and code. Any ideas would be greatly appreciated as I am new to
    Struts and Java programming and am really struggling with this one.



    acSearchResults is the original page mentioned above. acReadOnly is
    the secondary page.

    From struts-config.xml:

    <form-bean name="FrmACEditor"
    type="com.brodart.bdm.cataloging.form.FrmACEditor" />
    <form-bean name="FrmAcSearchResults"

    <action path="/AcSearchResultsInit"
    name="FrmAcSearchResults" scope="session" validate="false"
    parameter="method" input="/pages/acSearchResultsJSP.jsp">
    <forward name="success" path="/pages/acSearchResultsJSP.jsp"/>
    <action path="/AcSearchResultsPost"
    name="FrmAcSearchResults" scope="session" validate="false"
    parameter="method" input="/pages/acSearchResultsJSP.jsp">
    <forward name="success" path="/"/>
    <forward name="failure" path="/"/>
    <action path="/ACReadOnly"
    name="FrmACEditor" scope="session" validate="false"
    input="/pages/include/acReadOnly.jsp ">
    <forward name="read" path="/pages/includes/acReadOnly.jsp" />
    <forward name="failure" path="/pages/errorJSP.jsp" />

    From acSearchResultsJSP.jsp:

    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ include file="/pages/includes/tagLibs.jsp" %>
    <meta http-equiv="Content-Type" content="text/html;
    <title>Authority Control Search Results</title>
    <link rel="stylesheet" href="bdm.css">
    <SCRIPT LANGUAGE="JavaScript">
    <!-- // hide
    var showing
    var plus = new Image
    var minus = new Image
    var acRoWindow = null
    plus.src = "images/Plus.jpg"
    minus.src = "images/Minus.jpg"
    var numDatabases = <bean:write name="FrmAcSearchResults"

    function toggleDb(num)
    var strNum = num.toString()
    if (showing[num] == true)
    document.all["Div"+strNum].style.display = "none"
    showing[num] = false
    document.all["Div"+strNum].style.display = "block"
    showing[num] = true
    return true

    function initDisplay()
    showing = new Array()
    showing[0] = true
    for( var i = 1 ; i < numDatabases ; i++ )
    showing = true

    function closeAcWindow()
    { // All code commented out for testing
    // if ( acRoWindow != null && !acRoWindow.closed )
    // {
    // acRoWindow.close()
    // acRoWindow = null
    // }

    <body onload="initDisplay();" onunload="closeAcWindow();">


    <!-- This section is in an iterate to generate multiple bibId values
    and multiple links
    <a href="#"
    if(acRoWindow!=null)acRoWindow.focus(); return false;">My Link

    David Orr, Feb 17, 2004
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.