JavaFX is a new scripting language from Sun (I guess now from Oracle) for building Java-based rich user interfaces for the Web, mobile, desktop and even TV. There are plenty of sources on the Internet the predicted or predict the death of JavaFX. Based on what Oracle said few weeks ago, JavaFX has a bright future. We, at Exadel, after playing with JavaFX for some time (see Flamingo, JavaFX Eclipse plug-in) believe that JavaFX is actually a great language to build rich user interfaces, and not only for Java-based applications. JavaFX script can be extended to be used as a view description language (VDL) for JSF or even HTML5.
What does it mean? Well, you no longer have to mix HTML with JSF tags. The entire page is developed from JavaFX nodes (UI components), using JavaFX’s object-oriented nature. Layout it defined via JavaFX layout controls. It will be now be possible (finally) to create real visual and drag-and-drop editor for JSF.
Another very powerful feature in JavaFX is binding. Any changes in the model are automatically updated in the UI, it’s possible to extend the same to JSF. No longer you have to specify what components to render via Ajax, it will be done automatically by the application. More about this feature from Alex Smirnov’s blog.
We already have a first version of JavaFX as JSF VDL (we are still looking for better name, any suggestions?), and here is a quick example. When a button is clicked, the label Hello X is updated with the number of clicks.
var x = 0;
var bindVal = "Hello";
function init(){
FxPage{
content : [
FxForm{
content : [
FxOutputLabel{
value : bind bindVal
},
FxCommandButton{
value : "Button"
actionListener : function() : String{
bindVal = "Hello {x++}";
return null;
}
}
]
}
]
}
}
JavaFX script above is processed and a standard JSF UI component tree is created as with Facelets.
For now the model is created inside the JavaFX file, but we are working on allowing to bind to JSF managed beans or CDI beans.
As you can see JavaFX is a very powerful UI language. We will make this library available soon. It works with JSF 2.
You can read more about JavaFX as JSF VDL for Alex Smirnov’s blog.

Leave a reply to Miguel Garz Cancel reply