Struts and onunload event handler incompatible?

D

David Orr

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.

TIA,

David


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"
type="com.brodart.bdm.cataloging.form.FrmAcSearchResults"/>


<action path="/AcSearchResultsInit"
type="com.brodart.bdm.cataloging.action.ActAcSearchResultsInit"
name="FrmAcSearchResults" scope="session" validate="false"
parameter="method" input="/pages/acSearchResultsJSP.jsp">
<forward name="success" path="/pages/acSearchResultsJSP.jsp"/>
</action>
<action path="/AcSearchResultsPost"
type="com.brodart.bdm.cataloging.action.ActAcSearchResultsPost"
name="FrmAcSearchResults" scope="session" validate="false"
parameter="method" input="/pages/acSearchResultsJSP.jsp">
<forward name="success" path="/ACInit.do"/>
<forward name="failure" path="/AcSearchResultsInit.do"/>
</action>
<action path="/ACReadOnly"
type="com.brodart.bdm.cataloging.action.ActACReadInit"
name="FrmACEditor" scope="session" validate="false"
parameter="method"
input="/pages/include/acReadOnly.jsp ">
<forward name="read" path="/pages/includes/acReadOnly.jsp" />
<forward name="failure" path="/pages/errorJSP.jsp" />
</action>

From acSearchResultsJSP.jsp:

<%@ page contentType="text/html;charset=windows-1252"%>
<%@ include file="/pages/includes/tagLibs.jsp" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<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"
property="numDatabases"/>

function toggleDb(num)
{
var strNum = num.toString()
if (showing[num] == true)
{
document.all["Div"+strNum].style.display = "none"
document.images["Img"+strNum].src=plus.src
showing[num] = false
}
else
{
document.all["Div"+strNum].style.display = "block"
document.images["Img"+strNum].src=minus.src
showing[num] = true
}
return true
}

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

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

//-->
</SCRIPT>
</head>
<body onload="initDisplay();" onunload="closeAcWindow();">

<snip>

<!-- This section is in an iterate to generate multiple bibId values
and multiple links
-->
<a href="#"
onclick="acRoWindow=window.open('/BDM/ACReadOnly.do?acId=
<%=bibId%>&popup=true
','acRoWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=600');
if(acRoWindow!=null)acRoWindow.focus(); return false;">My Link
Text</a>

<snip>
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top