开发者

Passing javascript callback to java applet deployed using deployJava

开发者 https://www.devze.com 2023-01-26 12:27 出处:网络
I have an applet which is pretty long to start, but which is needed for my application to work. I used to register a javascript callback : jsAppletIsStarted.

I have an applet which is pretty long to start, but which is needed for my application to work.

I used to register a javascript callback : jsAppletIsStarted. This callback was called at the end of execution of the applet's start method.

The code looked more or less like this:

<script>
var jsAppletIsStarted = function(){/*do some useful stuff*/};
</script>
<applet id=".." etc>
<param name="appletStartedCallBack" value="jsAppletIsStarted "/>
</applet>

And it worked like a charm.

I had to switch to another way to start the applet : using the deployJava.runApplet() method.

The code now looks like this:

    <script>
    var jsAppletIsStarted = function(){/*do some useful stuff*/};

    var attributes = {};

 attributes.code = "myAppletClass.class";
 attributes.codebase="myCodeBase";

 var parameters = {};
 parameters.appletStartedCallBack="jsAppletIsStarted " ;

 var version = '1.6' ;
 deployJava.runApplet(attributes, parameters, version);
   </script>

And the callback is no more recognized. In my java console, I have the following error.

12:26:24,655 ERROR  com.mypackage.JavaScriptCallBack     - 
netscape.javascript.JSException: No such method "jsAppletIsStarted" on JavaScript object 
netscape.javascript.JSException: No such method "jsAppletIsStarted" on JavaScript object      
at sun.plu开发者_Go百科gin2.main.client.MessagePassingJSObject.newJSException(Unknown Source)  at 
sun.plugin2.main.client.MessagePassingJSObject.waitForReply(Unknown Source)  at 
sun.plugin2.main.client.MessagePassingJSObject.call(Unknown Source)  at 
com.mypackage.JavaScriptCallBack.callJsCallBack(JavaScriptCallBack.java:131) 
com.myapplet.MyApplet.start(MyApplet.java:662) at 
sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)  at 
java.lang.Thread.run(Unknown Source)

Is there a hack to pass the javascript callbacks as parameters to the applet for using with deployJava.js ?


Please try calling the function manually.

getAppletContext().showDocument(new URL("javascript:jsAppletIsStarted()"));
0

精彩评论

暂无评论...
验证码 换一张
取 消