Reputation: 145398
I have applet embedded in my HTML page. Nothing special:
<applet archive='static/app/applet.jar' code='appletclass/AppletClass'>
<param name='name' value='Applet name'>
<param name='mayscript' value='true'>
</applet>
Applet itself has method list
that performs some long lasting calculations. This method is called from the page with JavaScript:
try {
appletElement.list();
} catch (ex) {}
Of course long lasting calculations freeze the browser window until all calculations are completed.
Is there any workaround to work with applet in (somewhat) "asynchronous" way with no browser freezing? Does using threads in applet sources make any sense?
Thanks for help!
Upvotes: 0
Views: 1053
Reputation: 31
Using threads in the applet and then calling back to the page using JSObject would be the way to do this.
Upvotes: 0
Reputation: 3907
On page about mayscript attribute we can now find information:
LiveConnect is a technology that enables interaction between Java Applets and client-side scripts (such as JavaScript, VBScript). Older Java Browser Plugins (before Java version 1.6.0.10) do not allow applets to use LiveConnect by default, but that setting can be modified with the MAYSCRIPT attribute. Because of compatibility reasons (since Java Plugins in Internet Explorer always allow applets to access client-side scripts), newer Java Plugins (from Java version 1.6.0.10) do not check the MAYSCRIPT attribute, script access is always allowed in all browsers.
I've checked that on FF 18.0.1, Opera 11 or 12, Chrome and IE9 and this is working without any additional work (tutarial on oracle page - MAYSCRIPT is not needed, use only JSObject and import plugin.jar).
Upvotes: 2
Reputation: 2290
I am not sure about what you can do from within the applet, but from a simple javascript/html point of view you are stuck waiting in a synchronous fashion for calculations to complete. If you were fetching data from a server this would be different.
Upvotes: -1