United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6770422 HTMLTextAreaElement non-functional in plug-in2
JDK-6770422 : HTMLTextAreaElement non-functional in plug-in2

Details
Type:
Bug
Submit Date:
2008-11-12
Status:
Closed
Updated Date:
2011-02-16
Project Name:
JDK
Resolved Date:
2009-01-21
Component:
deploy
OS:
windows_xp
Sub-Component:
plugin
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
6u10
Fixed Versions:
6u12 (b02)

Related Reports

Sub Tasks

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.
                                     
2008-11-13
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/
                                     
2008-11-13
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.
                                     
2008-11-13



Hardware and Software, Engineered to Work Together