JDK-6770422 : HTMLTextAreaElement non-functional in plug-in2
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 6u10
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2008-11-12
  • Updated: 2011-02-16
  • Resolved: 2009-01-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6u12 b02Fixed
Description
FULL PRODUCT VERSION :
java version "1.6.0_10"
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
import java.lang.reflect.*;
import org.w3c.dom.*;
import org.w3c.dom.html.*;

/** Simple applet which fails to get an HTMLTextAreaElement from DOM */

public class DOMDump extends java.applet.Applet
{
    private HTMLTextAreaElement htae;

    public void start()
    {
        try
        {
            Class c = Class.forName("com.sun.java.browser.plugin2.DOM");
            Method m = c.getMethod("getDocument",
                                   new Class[] { java.applet.Applet.class });
            HTMLDocument doc = (HTMLDocument) m.invoke(null, new Object[] { this });
            htae = (HTMLTextAreaElement)doc.getElementById("textareaid");
            htae.setValue("This is a textarea");
        }
        catch (Exception e)
        {
            e.printStackTrace();
            System.out.println("Error with Java Plug-In");
        }
    }
}


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the applet source given below.  Then embed it in the following html document:


<html>
  <head>
    <title>
      DOM Dump test applet
    </title>
  </head>
  <body>
   <form method="post">
      <textarea name="textbox" id="textareaid" rows="25" cols="18"></textarea>
   </form>
    <applet code=DOMDump.class
      archive="DOMDump.jar"
      width=10 height=10
      mayscript>
    </applet>
  </body>
</html>



EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The text "This is a textarea" should show up in the textarea of the html page as soon as the applet starts.


ACTUAL -
No text shows up.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.ClassCastException: sun.plugin.dom.html.HTMLElement cannot be cast to org.w3c.dom.html.HTMLTextAreaElement
	at DOMDump.start(DOMDump.java:19)
	at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Error with Java Plug-In


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.lang.reflect.*;
import org.w3c.dom.*;
import org.w3c.dom.html.*;

/** Simple applet which fails to get an HTMLTextAreaElement from DOM */

public class DOMDump extends java.applet.Applet
{
    private HTMLTextAreaElement htae;

    public void start()
    {
        try
        {
            Class c = Class.forName("com.sun.java.browser.plugin2.DOM");
            Method m = c.getMethod("getDocument",
                                   new Class[] { java.applet.Applet.class });
            HTMLDocument doc = (HTMLDocument) m.invoke(null, new Object[] { this });
            htae = (HTMLTextAreaElement)doc.getElementById("textareaid");
            htae.setValue("This is a textarea");
        }
        catch (Exception e)
        {
            e.printStackTrace();
            System.out.println("Error with Java Plug-In");
        }
    }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Could not find one.

Release Regression From : 6
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

Comments
WORK AROUND Use the netscape.javascript.JSObject APIs to call into JavaScript to manipulate this DOM element.
13-11-2008

EVALUATION A typo in the table mapping element tag names to their associated classes caused HTMLTextAreaElement to be treated as a generic element, preventing useful interaction with it. This is not a recent regression. The bug has been there at least since Java 5.0.
13-11-2008

SUGGESTED FIX webrev: http://sa.sfbay.sun.com/projects/deployment_data/6u12/6770422.0 testcase: http://j2se.east.sun.com/deployment/www/tests/1.6.0_12/6770422/
13-11-2008