• 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

JApplet - Javascript communication

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,
This is a problem i am not able to go for hitting. I just don't understand how to attack it.
I have a japplet embedded in a html page. On the page there is some javascript code that has to access applet's public methods. All is well with IE but netscape doesnot recognize the document.appletName attribute. IT says there are no properties for the same.
I am using netscape (4.7 and 6 both) and IE 5.5.
Any hepls ....
please
regards
raghav..
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could use JavaScript to iterate through the document's children to see how NS wants you to refer to the applet. You would do this with something like:

This should pop up a dialog with the name of each child of the document object in the page with your applet. Then you could use the name of the applet as reported by Netscape to refer to it. If it doesn't show it as a child of the document object, well, that's another problem altogether. BTW, the applet isn't by any chance nested inside of a <FORM> tag or something, is it?
 
Raghvendra Sharma
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi there
thanks for the response. but while trying this, it is saying undefined for some arbitrary no of times. (The loop actually goes for 22 times , each time flashing undefined )
I might have a clue, the html page is plugin enabled, i.e. the tags that are being used to show the applet are embed and not applet. that could be a reason that the applets array is not being populated.
could that be a valid reason, and if you think yes, what could be the workaround. Its in a way necessary to have those embed tags since its a JApplet and they need to be shown that way only otherwise the browser jvm doesn't recognize that.
and strangely enough, when i try to access the applet by saying document.applets[0].<publicMethodName()>, the error i recieve is wierd enough, it says "no applet with index 9017352 . "
regards
raghav..

[This message has been edited by Raghvendra Sharma (edited May 03, 2001).]
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
from the JAVATM PLUG-IN HTML SPECIFICATION


A new addition for Java Plug-in 1.3 is the PARAM scriptable tag. This was added to improve performance of applets that do not require the use of JavaScript or VBScript. The value should be true if the applet requires scripting support and false if it does not. The value is false by default.
Please note that PARAM scriptable is not the same as the PARAM mayscript. Mayscript provides support for communication from Java applets to JavaScript only, while scriptable allows communication from JavaScript to Java applets in Internet Explorer only.


It seems that you must include a param tag with the value of MAYSCRIPT in order to allow JS to communicate with your applet in the EMBED tag or OBJECT tag. Also, you can give your EMBED or OBJECT an ID and a NAME. I would use ID and try to reference it that way.
Your problem of getting undefined 22 times just indicates that you don't have a NAME attribute in any of your HTML elements on your page.
HTH
 
Raghvendra Sharma
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot for your care about this topic,
but just to tell you, i had been through the specification about half an hour before and have already tried with both mayscript and scriptable.
It didn't work out. At least one or two mentions saying that Japplets cannot be accessed from within javascript have made me left my fight for getting it through.
Strangely enough java plug in page on sun, does talk about the use of javascript and java communication and threrefore mayscript but doesn't say a word in the section pertaining to the netscape's version of the plug in.
I hope i am not frustating you with my answers.
regards
raghav..

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not at all, because I haven't tried this myself with the plug-in yet. I have done some javascript-java communication with a JApplet, but I was using Netscape6, so I wasn't using the plug-in to test.
I'll try to put this to the test this weekend and let you know what I find out.
 
Raghvendra Sharma
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bodie,
Thanks for response.
Just to tell you the good news, Ultimately i have arrived at a conclusion sort of thing. JApplets can't be accessed through javascript in Netscape. I read that at one of the sun's forums.
As for the communication the other way is concerned, it is possible in both IE and NS by using netscape's JSObject classes.

And the JApplet access through javascript has been possible only through the plugin's presence and not otherwise.
hope you would help in the other way, (javascript - japplet) in netscape.
regards
raghav..
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a
[This message has been edited by Mayur Agrawal (edited December 20, 2001).]
 
Mayur Agrawal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a
[This message has been edited by Mayur Agrawal (edited December 20, 2001).]
 
Mayur Agrawal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sorry for mistake ,here is the code...
I was looking for some solution to a problem, when i came upon this page.
My problem was that I needed to call JApplet method through javascript function.
I was already using a plug-in, so I was tipped on by your discussion and my following $$OBJECT## tag worked...
PLEASE REPLACE ALL THE FOLLOWING $$ WITH < AND ALL THE ## WITH >
$$OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
WIDTH = 200 HEIGHT = 200 name = view codebase="http://java.sun.com/products/plugin/1.1.1/jinstall-111-win32.cab#Version=1,1,1,0"##
$$PARAM NAME = CODE VALUE = JTestApplet.class ##

$$PARAM NAME="scriptable" VALUE="true"##
$$COMMENT##
$$EMBED type="application/x-java-applet;version=1.1" java_CODE = TestApplet.class NAME = view WIDTH = 200 HEIGHT = 200 pluginspage="http://java.sun.com/products/plugin/1.1.1/plugin-install.html"##$$NOEMBED##$$/COMMENT##
$$/NOEMBED##$$/EMBED##
OBJECT##

here i think Object tag is for IE and Embed tag for netscape.I dont know about netscape but some similar solution should work.
Thanks
Mayur

[This message has been edited by Mayur Agrawal (edited December 20, 2001).]
 
reply
    Bookmark Topic Watch Topic
  • New Topic