Name: gm110360 Date: 06/04/2002
FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
EXTRA RELEVANT SYSTEM CONFIGURATION :
This bug manifests itself identically in both of the
following browers:
Internet Explorer Version 6.0.2600.0000
Product ID:55736-550-7011676-04000
Update Versions:; Q321232
Netscape 6.2.1
xxxxx/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4)
Gecko/20011128 Netscape6/6.2.1
A DESCRIPTION OF THE PROBLEM :
Applet code is using the Common DOM API to traverse and
manipulate the elements in an html <form>.
Calls to the getOptions() method of an HTMLSelectElement
object consistently return null.
(This may be related to bug #4675802, or may be a separate
problem.)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile the "DOMbug2.java" file below with the 1.4
SDK. "javac DOMbug2.java" is sufficient.
2. Copy the "DOMbug2.html" file below, and the
compiled "DOMbug2.class" file, to the same directory on a
computer where the Java plug-in has been configured to take
over hosting of the <applet> tag.
3. Open "DOMbug2.html" in either IE6 or NS6.2.1
EXPECTED VERSUS ACTUAL BEHAVIOR :
I expect the getOptions() method to return an
HTMLCollection containing three items.
Instead, it returns null and "getOptions() returned null."
is printed to the Java console.
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
------------begin DOMbug2.java---------------------
import java.applet.Applet;
import com.sun.java.browser.dom.*;
import org.w3c.dom.html.*;
public class DOMbug2 extends Applet implements DOMAction {
public void start() {
try {
DOMService service = DOMService.getService(this);
service.invokeLater(this);
} catch (Exception e) {
System.out.println("Caught " + e);
e.printStackTrace();
}
}
public Object run(DOMAccessor accessor) {
HTMLDocument doc = (HTMLDocument) accessor.getDocument(this);
HTMLCollection formList = doc.getForms();
HTMLFormElement form = (HTMLFormElement) formList.item(0);
HTMLCollection elementList = form.getElements();
HTMLSelectElement select = (HTMLSelectElement) elementList.item(0);
try {
/*
* the next line returns null, when it should return an HTMLCollection
*/
HTMLCollection coll = select.getOptions();
if (coll == null) System.out.println("getOptions() returned null.");
} catch (Throwable t) {
System.out.println("Caught " + t);
t.printStackTrace();
}
return null;
}
}
------------end DOMbug2.java-----------------------
------------begin DOMbug2.html---------------------
<html>
<head><title>Bug in the Common DOM API</title></head>
<body>
<h1>Bug in the Common DOM API</h1>
<form action="none">
<select name="selection">
<option>option 1
<option>option 2
<option>option 3
</select>
</form>
<applet code='DOMbug2.class' width='1' height='1' MAYSCRIPT></applet>
</body>
</html>
------------end DOMbug.html-----------------------
---------- END SOURCE ----------
(Review ID: 148126)
======================================================================
- duplicates
-
JDK-4803577 RFE: Common DOM API Enhancement
-
- Resolved
-