1

The best way to call applet methods from javascript file

asked 2014-01-25 22:36:00 +0800

venicum gravatar image venicum
21 4

updated 2014-01-25 22:46:54 +0800

Please help me to understand what is the right way to call an applet function from javascript? I tried get an applet like that:

 var cryptoApplet = jq("$cryptoApplet"); // and zk("$cryptoApplet");

I get "Uncaught TypeError: Object [object Object] has no method 'gettingFilesDirs'". I also tried other ways, but I allways get errors, like

  • document.getElementsByTagName('applet')[0] - "Uncaught Error: Error calling method on NPObject."

  • document.getElementById("cryptoApplet") - "Uncaught TypeError: Cannot call method 'gettingFilesDirs' of null"

  • zk.Widget.$('$cryptoApplet') - "Uncaught TypeError: Object [object Object] has no method 'gettingFilesDirs'"


In my index.zul file I have the following code:

 <applet id="cryptoApplet" code="com.it.projects.crypto.CryptoApplet" 
    archive="cryptoclient-0.0.1-SNAPSHOT.jar" 
    width="1" height="1"/>
 <script src="/js/crypto.js"></script>
 <script src="/js/testCrypto.js"></script>
 <button id="bEncryptZip" label="Choose file and encrypt" 
      xmlns:w="<no links>zkoss.org/2005/zk/client"
      w:onClick="testZipEncryptClient();" >
 </button>

The "cryptoApplet" has to be hidden (but it isn't). "testZipEncryptClient()" in testCrypto.js script file:

 function testZipEncryptClient() {
      var cryptoApplet = document.getElementById("cryptoApplet"); // for example
      var fileNames = gettingFilesDirs("*", "1", "1");
      cryptoApplet.zipEncryptClient(fileNames, "123qweASD", 
           "169526916271186875847950195488343319456", 
           "<cert in base64>");
 }

Method "gettingFilesDirs(...)" from crypto.js:

 function gettingFilesDirs(extFile, fileDir, multi) {
      var cryptoApplet = jq('$cryptoApplet'); // for example
      return cryptoApplet.gettingFilesDirs(extFile, fileDir, multi);
 }
delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-02-06 06:07:39 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

updated 2014-02-06 06:07:52 +0800

Hi, you can try to log the jq selector

zk.log(jq('$cryptoApplet'));
zk.log(zk.Widget.$(jq('$cryptoApplet')));
zk.log(zk.Widget.$('cryptoApplet'));
link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2014-01-25 22:36:00 +0800

Seen: 23 times

Last updated: Mar 06 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More