Skip to main content

JRE 1.6.0_10 and JS->Java communication

2 replies [Last post]
srgray
Offline
Joined: 2008-11-25

I just upgraded to JRE 1.6.0_10 and now it seems that my JavaScript -> Java applet communication is not working anymore. If I revert to 1.6.0_7, it works fine.

Here is my applet code:

import javax.swing.JApplet;
public class SimpleApplet extends JApplet {
private static final long serialVersionUID = -681454679772431812L;
/** Initializes the applet GOSEApplet */
public void init() {
try {
java.awt.EventQueue.invokeAndWait(new Runnable() {
public void run() {
System.out.println("SimpleApplet.init()");
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}

public void start() {
System.out.println("SimpleApplet.start()");
}

public void stop() {
System.out.println("SimpleApplet.stop()");
}

public void destroy() {
System.out.println("SimpleApplet.destroy()");
}

/*
* Meant to be called by JavaScript on HTML page
*/
public void echoPrint(String message) {
System.out.println("In SimpleApplet.echoPrint(): "+message);
}
}

And here is the HTML page:

SimpleApplet

document.simpleApplet.echoPrint("TEST1");

I expect to see 3 print outs:
SimpleApplet.init()
SimpleApplet.start()
In SimpleApplet.echoPrint(): TEST1

But, I don't see the last print out.

Any ideas?

-Stephen

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
macintyrei
Offline
Joined: 2008-03-26

looks to be some timing issue or something. If I change your html to the following it works (I put your javascript inside a function, and call it from body onload)

[code]


SimpleApplet



[/code]

rogyeu
Offline
Joined: 2006-07-30

Thanks for reporting the issue and the workaround. I have opened a bug report for this issue. Bug ID is 6776473. You can monitor the issue at: http://bugs.sun.com/view_bug.do?bug_id=6776473 .

It may take a day or 2 for it to show up in the external database.

Thanks,
Roger Y.