JavaFX as JSF VDL (View Description Language)?

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.

18 thoughts on “JavaFX as JSF VDL (View Description Language)?

  1. While it’s certainly an interesting experiment, I strongly disagree with the idea. When you use JSF to render HTML pages you are basically still doing HTML. JSF puts a nice abstraction on top of this by using components which encapsulate a lot of the (rendering) complexity. Besides those components however, you still have to style/structure your pages and that’s most easily done by just using HTML/CSS. In a real JSF application you will always find a mixture of HTML tags and JSF component tags. By abstracting even further away from HTML by using a complete different language, it’s going to be even harder to create a decent look & feel.

  2. Pingback: JavaFX as JSF VDL (View Description Language)? | 007Nova Articles

  3. @Paul Bakker: you will still be able to style with CSS. As for layout, you will use JavaFX layout controls. Thanks for the feedback, we are trying it out ourselves, we’ll see where it goes. The idea is not far from how GWT works.. you write in Java and get HTML/JavaScript. In this case you use JavaFX which we believe is an excellent language to build UIs.

  4. When you mention JavaFX are you referring to using JavaFX Script as the JSF VDL? Not to be mixed up but JavaFX is the platform and JavaFX Script is the programming language.

    This is certainly not as confusing like having both the word Java being used to refer to the platform and the programming language. Now that is confusing when trying to find out if its Java the programming language, or Java the platform whenever the word Java is mentioned.

  5. @Nick: I’m referring to JavaFX Script in this post (you would still get HTML application). However, it would be pretty easy to change a setting and deploy it as an applet or even Java Web Start.

  6. Pingback: JavaFX links of the week, February 15 // JavaFX News, Demos and Insight // FX Experience

  7. Pingback: Java desktop links of the week, February 15 | Jonathan Giles

  8. Actually, I think that even a better use for JavaFX script would be to be compiled into HTML & Javascript like GWT. JavaFX Script’s syntax is a perfect fit for client-side HTML development.

  9. @pron: In fact, it’s something we are looking at as well. It might be a better fit than to generate HTML/JavaScript than to use it as VDL for JSF.

  10. Hi , maybe the name XFaces or Facex ?
    I would like to know some reference on how to communicate a JFX aplication with the serverside, like the managed beans… does anybody has any idea on that ?

  11. Pingback: JavaOne 2010: review, thoughts, and what happened with JavaFX (part 2) | Maxa Blog

  12. > By abstracting even further away from HTML by using a complete different
    > language, it’s going to be even harder to create a decent look & feel.

    This reminds me of the comment I just heard in the Unsupported Operation podcast which said something like “one problem with Wicket is that the Java code drives the HTML page it should be the other way around”.

    Not sure if it is completely realistic to replace/eliminate HTML when developing WebApps. GWT is trying, and it seems to be the plan for JavaFX 2.0, but I have a feeling that HTML is still needed, so Facelets is the way to go.

  13. Pingback: Authoring JSF pages in pure Java | J-Development

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s