Microsoft KB Archive/242014

= FIX: Event Scripting Breaks for Multiple Java Beans on the Same Web Page =

Article ID: 242014

Article Last Modified on 6/14/2006

-

APPLIES TO


 * Microsoft Internet Explorer 4.0 128-Bit Edition
 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Internet Explorer 4.01 Service Pack 1
 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Internet Explorer 5.0
 * Microsoft Internet Explorer 5.01
 * Microsoft Internet Explorer (Programming) 5.01 SP1

-



This article was previously published under Q242014



SYMPTOMS
When you script Java bean events in Internet Explorer, some events may not be fired if more than one bean exists on the same Web page.



CAUSE
This problem is caused by the browser's caching of type information for Java bean objects that are hosted on a Web page.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in Internet Explorer 5.5.



Steps to Reproduce Behavior
  Create a new .htm file named Page1.htm, and paste the following code:Page1.htm  function generateAppletOneEvent {   alert("Script event function called for applet one."); window.document.EBAppletOne.generateEvent; }

function generateAppletTwoEvent {   alert("Script event function called for applet two."); window.document.EBAppletTwo.generateEvent; } Multiple Applet Event Bug Test  alert(source + " fired an event.");  alert(source + " fired an event.");   Compile the following Java source files:EBAppletOne.java import java.awt.*; import java.applet.*; import java.util.*;

public class EBAppletOne extends Applet { private Vector listeners; public void init { Label l = new Label; l.setAlignment(Label.CENTER); l.setText("This is applet one."); add(l); } public void generateEvent { try { if (listeners == null) return; Enumeration e = listeners.elements; while (e.hasMoreElements) { EventObject eo = new EventObject(this); ((EBAppletOneListener)e.nextElement).onEBAppletOneEvent(eo); System.out.println("Event fired from applet one: "+eo.toString); }   }    catch (Exception ex) { ex.printStackTrace; } }

public void addEBAppletOneListener(EBAppletOneListener list) { if (listeners == null) listeners = new Vector; listeners.addElement(list); } public void removeEBAppletOneListener(EBAppletOneListener list) { if (listeners != null) listeners.removeElement(list); } } EBAppletTwo.java import java.awt.*; import java.applet.*; import java.util.*;

public class EBAppletTwo extends Applet { private Vector listeners; public void init { Label l = new Label; l.setAlignment(Label.CENTER); l.setText("This is applet two."); add(l); }

public void generateEvent { try { if (listeners == null) return; Enumeration e = listeners.elements; while (e.hasMoreElements) { EventObject eo = new EventObject(this); ((EBAppletTwoListener)e.nextElement).onEBAppletTwoEvent(eo); System.out.println("Event fired from applet two: "+ eo.toString); }   }    catch (Exception ex) { ex.printStackTrace; } }

public void addEBAppletTwoListener(EBAppletTwoListener list) { if (listeners == null) listeners = new Vector; listeners.addElement(list); } public void removeEBAppletTwoListener(EBAppletTwoListener list) { if (listeners != null) listeners.removeElement(list); }

} EBAppletOneListener.java import java.util.*;

public interface EBAppletOneListener extends EventListener {   public void onEBAppletOneEvent(EventObject e); } EBAppletTwoListener.java import java.util.*;

public interface EBAppletTwoListener extends EventListener {   public void onEBAppletTwoEvent(EventObject e); }                    Copy the resultant .class files to the same folder as the Page1.htm file.

NOTE: These files do not need to be on a Web server to demonstrate the problem. In Internet Explorer, open Page1.htm.</li> Click the applet buttons to generate bean events. Only one of the applets or beans fires events to the Web page script handlers.</li></ol>

<div class="references_section">