JDK-5038583 : Plugin causes JSP to open behind browser window with applet
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.2_04
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2004-04-27
  • Updated: 2004-05-14
  • Resolved: 2004-05-14
Related Reports
Duplicate :  
Description
The test case below shows that a JSP called by Javascript in an HTML page with an applet opens behind the first browser window.  This appears to be a regression in 1.4.0 - the test case works with 1.3.1_02 and 1.3.1_11, but does not work with 1.4.0, 1.4.0_04, 1.4.1_07, or 1.4.2_04.  Note that if the plugin console window is shown instead of being hidden, the problem does not occur.  Also note that the problem exists with both IE and Netscape.



Test case:

-------------------------------------------------------------------------------

mr_ie.htm:
------------


<HTML>
<HEAD>
<TITLE>Logon to WebFOCUS MRE</title>
<SCRIPT LANGUAGE="JavaScript">

function openHTMLTool()
{   var strURL = "";
    strURL += "rpasstie.jsp";
    var rptoolForm = document.getElementById("rptool");
    rptoolForm.action = strURL;
    rptoolForm.submit();  
}

function ibilangtransonload()
{  alert("DEBUG");
   var innerHTML = "<APPLET CODE='PanelTest2.class' MAYSCRIPT NAME='PanelTest2' ID='PanelTest2' HEIGHT=475 WIDTH=700>";
   innerHTML += "</APPLET>";
   document.getElementById("layerDomainAdmin").innerHTML = innerHTML;
   return;
}
</script>
</head>
<BODY ONLOAD="ibilangtransonload()">
<DIV ID="layerDomainAdmin" STYLE="display=block"></div>
<DIV ID="layerHTMLRA" STYLE="display:none">
  <FORM ID="rptool"
        ACTION= base +"/javaassist/ibi/html/assist/jsp/rpasstie.jsp"
        METHOD="post"
        TARGET="rpWin">
  </form>
</div>
</body>
</html>


------------------------------------------------------------------------------


PanelTest2.java:
-----------------

import java.applet.Applet;
import java.applet.AppletContext;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import netscape.javascript.JSObject;    
import netscape.javascript.JSException; 

public class PanelTest2 extends Applet{
    Vector bloppo = new Vector();
    JavaScript jscript; 
    public void init()
    {
     Button eButton = new Button("GOFORIT");
     Panel center = new Panel();
     center.add(eButton);
     add(center);
     jscript = new JavaScript(this);
     System.out.println("Before call - watch for alert.");
      jscript.call("openHTMLTool",bloppo);
      System.out.println("After call ");
    }
}// end of class



--------------------------------------------------------------------------------


JavaScript.java:
-----------------

import java.applet.Applet;
import java.applet.AppletContext;
import java.util.Vector;
import netscape.javascript.JSObject;
import netscape.javascript.JSException;

public class JavaScript extends Object {
    private Applet applet;
    private JSObject wind = null;
    
    public JavaScript(Applet inApplet) {
       this.applet = inApplet;
    }
  
    public boolean call(String functionName,Vector arguments) {
        String [] args;
        System.out.println("the function name is " + functionName);
        JSObject window=null;
        try {
            window = JSObject.getWindow(applet);
            JSObject doc = (JSObject)window.getMember("document");
            JSObject loc = (JSObject) doc.getMember("location");
            String s = (String)loc.getMember("href");
            System.out.println("document.lication.href: " + s);
            if (arguments == null) {
                args=null;   
            }
            else {
                int size=arguments.size();
                args=new String[size];
                for (int index=0;index<size;index++) {
                    args[index]=(String) arguments.elementAt(index);
                }
            }
            if(wind != null)
              window = wind;
            window.call(functionName,args);                        
            if (false) 
                throw new netscape.javascript.JSException();     
        }
        catch (netscape.javascript.JSException ex) {
            println("Javascript exception");
            println("Leaving 0001 call");
            ex.printStackTrace();
            return false;
        }
          catch (Exception ex) {
            println("ComFailException exception"+ex.toString()+", calling: "+functionName);
            println("window.toString()"+window.toString());
           
            println("Leaving 0002 call");
            return false;
        }
        return true;
    }    

    private void println(String s) {
        System.out.println("JavaScript: "+s);   
    }
}



---------------------------------------------------------------------------------------


rpasstie.jsp:
--------------

<%@ page language="java" contentType="text/html" %>
<HTML>
<HEAD>
<TITLE>THE JSP IN THE BACKGROUND</title>
</head>
<BODY 
 <TR><TD> I GOT BURIED.</td></tr>
</body>
</html>
###@###.### 2004-04-27
###@###.### 2004-04-28
###@###.### 2004-04-30

Comments
EVALUATION Name: atR10251 Date: 05/13/2004 Our current behaviour is the next: - while starting an applet a) EmbeddedFrame is activated; b) focus is requested for its default component. This doesn't give a chance for any non-java component (or window) to get focus (if it was activated before the applet started). The similar problem exists in 4984794 "Invisible applet steals focus from HTML form field". This issue can be resolved if we will activate EmbeddedFrame only when it is already focused. If not focused we skip a) item and perform b). But what if between a) and b) EmbeddedFrame loses focus? Focus will be taken away from that non-java component holding it. It's a problem to think over... The better way would be to allow user to choose strategy: 1) allow applet to request focus; 2) forbid applet to request focus. The similar (or the same) approach is implied in 4984794. ###@###.### 2004-05-13 ======================================================================
13-05-2004