NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/

Easy Java Simulations (2001- ) => Questions related to EJS => Topic started by: Jimmy Lefort on April 10, 2009, 05:10:53 pm



Title: JSObject
Post by: Jimmy Lefort on April 10, 2009, 05:10:53 pm
Hi

I am a french student in an engineering school. I am using ejs to make some java applet. I would like to make my java applet communicate with an html web page. For that, I need to use a JSObject in my applet. ( http://java.sun.com/products/plugin/1.3/docs/jsobject.html)

I have imported the JSObject library in ejs, but my problem is that  ejs seems to not recognize the JSObject and all functions.

Do you know if it is possible to use a JSObject with ejs?

Thanks,

Jimmy Lefort


Title: Re: JSObject
Post by: Fu-Kwun Hwang on April 10, 2009, 08:15:58 pm
Please let me know what you want to do?
Do you want to call EJS with Javascript or do you want to call Javascript from EJS?


Title: Re: JSObject
Post by: Jimmy Lefort on April 10, 2009, 09:11:06 pm
Hi,

Actually, I would like to send a value (an integer for example) from my Java applet to the javascript code. I have seen on the web that it is possible with a JSObject. Do you know if it is possible to do that with ejs?

Thanks a lot for your help.

Jimmy LEFORT


Title: Re: JSObject
Post by: Fu-Kwun Hwang on July 27, 2009, 09:56:02 pm
It will be much easier to get value in EJS with javascript call.
All the variables defined in EJS model can be access directly with javascript call.
For example:
if the name in applet tag is ejscode (name='ejscode')
And there is a variable call dt in ejs model.
You can get dt value with the following call:
dt=document.ejscode._model.dt;

Please check out Quiz: Do you know when two particles have the same horizontal speed? (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=714.0)

I added JSObecj to EJS version 3 so that I can call javascript in the same html page from EJS simulation.
It was only work for Internet Explorer and it is not working for netscape at that time.
However, the code has been disabled in the current version.
It is at the end of org/colos/ejs/library/simulation.java
You can try to enable the code and re-compile it again if you really need it.