View Single Post
Old 10-16-2003, 02:47 PM   #1 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,175
Belisarius is on a distinguished road
Brief popup under IE

I think this is a javascript under IE problem, as I got it to work successfuly under Opera.

I want to have a locking mechanism for certain webpages so that only one person can have interactive access at any given time. Of course, I want them to give up the lock upon leaving the page. The best way I could think of doing this (via JSP) was to popup a window that contained the release code via the onUnload function.

Here are the relevant code snippets:

On the page in question:
Code:
 <snip>

function releaseLock(){
      window.open("releaseLock.jsp?lock_name=<%=request.getParameter("id")%>", "Release Locks");
}

<snip>

<body onUnload="releaseLock()">
Here's the release lock popup code:

Code:
<jsp:useBean id="user" class="dec.common.beans.UserBean" scope="session" />

<%@ page import="dec.common.locks.*" %>
<%@ page import="dec.common.authentication.*" %>

<%
  String lock = request.getParameter("lock_name");
  if(lock != null){
    lock = lock.trim();
    LockMap.getInstance().release(lock, user.getUser().getUID());
  } // If lock == null, do nothing.  Something broke, and the lock that was suppose
    // to be released will have to expire.
%>
  <html>
    <head>
    </head>
    <body onLoad="window.close()">
     <a href="javascript:void(0)" 
       onClick="window.close()"</a>
    </body>
  </html>
Now, the problem is that when I close the window, the popup doesn't seem to open, and the lock remains in place. Again, this happens under IE, but not Opera. I would have tested it under Mozilla, but one of the Javascript operations (refering to a window's opener) didn't work.
__________________
GitS
Belisarius is offline   Reply With Quote