JavaFX and Ajax

Ken Russell, the architect and author of the new Java Browser plugin has recently completed the work on the JavaFX to JavaScript bridge. In a nusshell, JavaFX web applications could call JavaScript functions & objects in the webpage that embeds the JavaFX app and vice versa. Nota bene: this bridge calls for the plugin to use Java SE 6 update 10 or later.

JavaScript to JavaFX Script

JavaFX Script can be accessed using the synthetic script field which is exposed from JavaFX Script applets to the JavaScript engine.

function someJavaScriptCall() {

var myApp = document.getElementById("myApplet";);

myApp.script.someJavaFXScriptCall();

}

The snippet above, assumes that the Java web application (Applet) embedded in the web page is instantiated with myApplet as id.

JavaScript to JavaFX Script

JavaFX Script can interact with JavaScript on the web page, in a similar way to how Java code can interact with JavaScript. This lets you call JavaScript functions defined on the web page, modify the Document Object Model (DOM) of the web page on the fly, and generally write JavaFX Script apps that integrate well within the web page.

AppletStageExtension.eval("yourJavaScriptCall()";);

Comments:

Very cool! I might finally start using JavaFX. Thank you for this REALLY useful bridge.

Posted by Kevin Hutchinson on March 12, 2009 at 08:22 AM PDT #

Ken Russell is god-like!
(lower case g of course)
Great job!
Thom

Posted by Thom Theriault on March 13, 2009 at 02:31 AM PDT #

Sweet!! So this bridge goes away if the user drags the applet out of the browser, right?

Posted by Eric Wendelin on March 20, 2009 at 07:41 AM PDT #

Eric, the bridge is still alive until you switch to diff tab or close the browser (this is obvious :-)).

Posted by Octavian Tanase on March 20, 2009 at 09:30 AM PDT #

Post a Comment:
Comments are closed for this entry.
About

octav

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today