Both Java Script and JavaFx Script are client side script technologies which imparts dynamicity and interactivity to the web pages,decreases the server load by performing the required calculation,and other process within the client side.

Javascript Script can be directly embedded in the HTML,JSP pages via Script tag or written in separate js file which can be included in the web pages.On the other hand JavaFx Scripts technology is used within the JavaFx(RIA) Technology.

JavaFx Technology is one among the (RIA)Rich Internet Applications developed by Sun Microsystem. It is a GUI like Swing giving a pleasant look and feel to the web pages,JavaFx technology can be used to develop stand alone(LAN) applications and Web applications.In a web application JavaFx files can be embedded in the HTML files similar to the applets.Hence we can say that (HTML+Java Script=JavaFx GUI+JavaFx Script) combination forms the client side technology.Communication between Java Script and JavaFx Script is possible in the web pages where it is used which in turn increases the performance of web pages.

Java Script Access To JavaFx Script

Java Script code can access the variable,call functions,set and get variables of a JavaFx.This is applicable to new version of Java Run Time S/W Java SE 6 update 10 .Attempting to work this on earlier version will throw exception can be caught by try()catch() of Java Script

* Accessing JavaFx Script variables

If you have a variable “color” JavaFx Script Applet embedded in your web page with id “FxApplet” you can access the variable color in your java script by

JS Code-” var fxApp = document.getElementById(“FxApplet”); ”
JS Code-” fxApp.script.color = fxApp.Packages.javafx.scene.paint.Color.RED; ”

*Calling JavaFx Script Methods in Java Script:

You can simply call a JavaFx Script function setColor() in side Java Script Code by

JS Code-” fxApp.script.setColor(); ”

Data of different types such as int,boolean,char etc can be passed to and fro . It is also possible to supports data type conversion eg: int data can be transferred to String,Java Script can pass arrays to JavaFx Script which greatly facilitates the animations and JavaFx Script returns sequence which can be accessed by JS in array format,Other than JavaFx object,Java Object can also be accessed by Java Script.

*Calling Java Script Method in JavaFx Script:

JavaFx Script can eval() Java Script function by importing the AppletStageExtension Class in javaFx package

JFX Code-import javafx.stage.AppletStageExtension ;
JFX Code-AppletStageExtension.eval(“jsFunction()”);

Also there is provision for manipulating the DOM object using JavaFx Script.

These sought interaction between two technologies opens a new window to explore vast possibilities to develop web pages and redefines the way of web development.