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" 
    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();" >

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", 
           "<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

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

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

1 follower



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