• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Calling Javascript method in js file from Applet

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am attempting to call a javascript function (residing in a js file) from an applet to update a ProgressBar element. My method updateProgressBar() is located in data.Import.js and I include this file in the html page, which is why I dont understand why I am getting a "updateProgressBar function is undefined" error message. Is there some extra something Im supposed to put in the URL to let it know to look in my data.Import.js for the function?

In HTML:
<script src="data.Import.js" type="text/javascript">

In Applet:


I tried stuff like new URL("javascript:data.Import:updateProgressBar()"); but I got an invalid label error. I was also sure to put the MAYSCRIPT and scriptable parameters on my applet. My applet is setup as follows, and may be the cause of the function not found: initial applet class instantiates a thread class, which then instantiates and runs my upload class. This upload class is what is needs to call the javascript function.

I have also tried using the LiveConnect methods such as:

But I haven't had any success with that either, as I get this error message in the Java Console: "No such method "updateProgressBar" on JavaScript object" Previously, this main upload class opened a new window, so that may be causing it to have a different document/window object, but I am changing it so that it no longer opens a new window.

Any help would be greatly appreciated.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you setting the MAYSCRIPT attribute in the applet tag?
 
T Almo
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I am using the MAYSCRIPT attribute, as I mentioned above.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah, I missed that. The LiveConnect code works fine for me if I put it in the paint method. It seems that the web page isn't fully loaded and initialized if the code is in the init method.


 
T Almo
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it possible that the newFrame I create and pass to the FileDialog is what my JSObject window and document is referring to? My thought is that either the JSObject isnt referring to the right thing, or the threading I described above has something to do with it.

 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure what the "myApplet" parameter is that you were using in the getWindow call, but if you use "this" like in my code then the JSObject should refer to the enclosing web page.
 
T Almo
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The myApplet parameter is the Applet. I have to use that parameter because this window.call function runs in a child class of the main class that extends Applet(the threading setup I described in the first post). I pass the applet itself to the subclass.
 
T Almo
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just had an interesting observation. I made a separate, simple test page similar to yours, and when the updateProgressBar function was only an alert, it worked fine, but if I changed it to document.write(s), I got the same 'JSException: No such method "updateProgressBar" on JavaScript object' I think this is related to the threading my program implements. All I am trying to do is update the progress bar on an ExtJS element, so its apparently the same reason document.write is failing.

I dont have complicated threading at all. As I described earlier, all that happens is my main applet class calls an uploadThread class, which then starts the upload class in a new thread, and that new thread runs the whole time until its done.
 
T Almo
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I solved it. The problem was that the js file in which the function resided was an ExtJS class, so I had to get at it with the following applet code:


When I created my ExtJS component, I gave it the id myUploadWindow, so I could grab it with the get command. Thank you for your help.
 
It's never done THAT before. Explain it to me tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic