Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Java data and javascript

Status
Not open for further replies.

RedGhost

Programmer
Jul 7, 2000
11
0
0
US
Is there some way to make java and javascript communicate, so that I get a javascript variable (an array of string) pointing on the result of a java method (an array of string) ?
 
can you clearly define how you'll use this? I'm not sure what you mean... you can have JavaScript write to the screen and include it as a parameter to an applet, if that's what you need... <p>Liam Morley<br><a href=mailto:lmorley@wpi.edu>lmorley@wpi.edu</a><br><a href=] :: imotic :: website :: [</a><br>"light the deep, and bring silence to the world.<br>
light the world, and bring depth to the silence.
 
You can also have <br><br>try <br>{<br>AppletContext context = getAppletContext();<br>URL u = new URL(getCodeBase(),javascript: &quot;name of function&quot;);<br>context.showDocument(u,frame);<br>}<br>catch(Exception error)<br>{<br>showStatus(&quot;Error &quot; + error);<br><br>}<br>}<br>this should allow you to load a javascript function when this peice of code is run, i am not positive how this works or if it does at all i just remember seing it some place.<br><br><br> <p>moses<br><a href=mailto:tmoses@iname.com>tmoses@iname.com</a><br><a href= my site</a><br>"In the beginning there was HTML, and it was good"<br>
by Nick Heinle, Designing with JavaScript<br>
<br>
<br>
 
&gt; get a javascript variable (an array of string) pointing on the result of a java method (an array of string) ? <br><br>&quot;pointing on the result of a java method&quot;<br><br>uh? I don't follow that at all. Is that a new technical term that I am not familiar with?<br><br>-pete
 
I'll try to make myself clearer (it will be all the easier since I thought a little about it:) ). So, I have a java applet. It deals with files, so I have d/l the java plugin and I call the applet via an OBJECT tag and not an APPLET tag.<br>What I would like to do is calling a function of the applet in a javascript and get its results. So, two problems :<br>- the normal syntax used for calling a java function is an applet is : document.applet_name.function_name, and it doesn't work because of the OBJECT tag ;<br>- can you actually write this :<br>&lt;script language=&quot;javascript&quot;&gt;<br>function boo ()<br>{<br>&nbsp;&nbsp;var myVar=document.applet_name.funct(50);<br>}<br>&lt;/script&gt;<br>with applet_name an applet and funct a java function :<br>int funct(int param)<br>{<br>// body...<br>}<br>?<br><br>
 
&gt; can you actually write this :<br><br>Yes, I know, I do it all the time.<br><br>&gt; so I have d/l the java plugin and I call the applet via an OBJECT tag and not an APPLET tag.<br><br>Well I don't know what 'd/l the java plugin' is but obviously that is what is creating the problem. <br><br>&gt; Is there some way to make java and javascript communicate<br><br>Since you already know how to communicate to an applet from a javascript... I'm not sure what your question is?<br><br>If 'd/l the java plugin' is a binary product then I can think of&nbsp;&nbsp;3 choices for your options.<br>1) You could stop using it<br>2) Find out from the makers of the product if they provide an interface from script to the product as a proxy to the nested applet.<br>3) Magic! (NOTE: I don't think this will work)<br><br>-pete
 
'd/l' stands for download. As for the java plugin (it's from Sun and it's free, by the way), I can't stop using it since it's needed if you want your applet to deal with files (else you have to put up with security restrictions ; it results in annoying exceptions such as 'AccessControlException'). And the only way to make IE use the plugin with the applet is calling it with an OBJECT tag. But then it's considered (the applet) like an ActiveX object, and I've never dealt with ActiveX before, and haven't found anything helpful on sun.java.com (ie, they explain how to use the plugin but not how to call a method from a script).<br>Unfortunately, my magic.txt file was in the bad place at the bad time the last time my drive went clean.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top