Alexander Smirnov’s personal Weblog

May 28, 2009

JavaFX as JSF 2.0 VDL

Filed under: Java, Java server faces — Tags: , , — alexsmirnov @ 5:13 pm

JavaFX as JSF 2.0 view description language.

Preface

The JavaFX language has been developed for Rich Internet Applications. The project FAQ says:

“JavaFX is an expressive rich client platform for creating and delivering rich Internet experiences across all screens of your life. JavaFX 1.0 was released on December 4, 2008. As of February 1st, 2009, there had already been over 100,000 downloads of the tools and SDK. Today, JavaFX is available on over 50 million desktops.” In spite of that is really means applets or Java Web Start applications, I was a curious: Is that would be useful for web applications also ? Take look at the description from the OpenJFX compiler site:

What is JavaFX Script?

  1. automatic update (bind)

  2. list comprehensions (sequences)

  3. easy-to-use

  4. runs on JVM

  5. interacts smoothly with Java

  6. easy natural object graph creation (object literals)

  7. graphics centric

  8. single threaded

  9. focused on small to medium scale applications

  10. curly-brace language

Ok, take a look for these features :

  1. Bind. This is most attractive for me as capability for the JSF Ajax . Instead of manual definition for ‘dirty’ parts of page; as it implemented in the RichFaces, JSF 2.0 and some other projects, or analyzing differences in the rendered HTML code as the IceFaces project does, application can update these parts of page only where model values was changed. That would simplify application development on the same way as for Swing.

  2. Not sure how is that applicable for a web application.

  3. That is always necessary.

  4. I.e. in the same environment as JSF works.

  5. Good for JSF/JEE applications too.

  6. Very attractive for JSF application because of the tree-like view structure.

  7. Not web advantage.

  8. That doesn’t mean real single threaded implementation, I guess, because JavaFX GUI is based on Swing which uses threads, but hides thread manipulation from the application developer. It would be funny for web applications if we could put discrete requests processing behind developer’s concern.

  9. Really, that is a main target for JSF applications too.

  10. Not sure about that.

So, at least seven from ten JavaFX features are applicable to JSF Web. But additional advantages are pure object-oriented language, type safety …

Implementation idea

The one of the new JSF features is pluggable View Declaration Language. Chapter 7.6 of the Java Server Faces Specification says:”A View Declaration Language (VDL) is a syntax used to declare user interfaces comprised of instances of JSF UIComponents.”. The simplest way to integrate JavaFX with JSF is ViewDeclarationLanguage implementation that creates tree of JSF UIComponents from the JavaFX script. For example, if user requests page “ http://foo.com/bar/baz.fx” that implementation should execute “/bar/baz.fx” script from the web application content or load and execute pre-compiled “bar.baz” class. The script should create the tree of JSF UIComponents in the same way as any other JSF VDL does. Really, in the research prototype VDL implementation expects instance of the special “ JavaFXHandler” interface that creates UIComponent instances in the “ apply” method. That simplifies script content and allows to cache results between requests. Therefore, a simple JavaFX page would seem like this ( that is part of JSF 2.0 version of the guess number example page ):


import org.richfaces.javafx.*;

View {
  children:[
    Head {
      children:[
         Title {
              value: "GuessNumber 2.0&amp"
         },
         StyleSheet {
              value: "css/styles.css"
         }
      ]
    },
    Body {
         bgcolor:WHITE
       children:[
          Form {
              id: "helloForm&amp"
            children:[
               H2 {
                      value: "{userNumberBean.greeting}"
               },
               Image {
                  src:"{resource['images/wave.med.gif']}"
                  alt:"Hello!"
               }
               InputText {
                  label:"User Number",required:true
                  value: bind userNumberBean.userNumber
                  id:"userNo"
                  converter: NumberConverter {integerOnly:true}
                  validators: [
                                 GuessNumberValidator {
                                     min:userNumberBean.minimum
                                     max:userNumberBean.maximum
                                 }                                 

                              ]
               },
               CommandButton {
                  value: bind userNumberBean.userNumber
                  id:"submit"
                  action: Action {viewId:"response",redirect:true}
               }
          }
       ]
    }
  ]
}
Advertisements

10 Comments »

  1. You have less than an hour to get your grapes harvested after they are ripe before they go bad.
    You should go to “My Neighbors” and help your neighbors out
    for coins and XP. One friend told the New York Post that she is a “gold digger.

    Comment by Marina — January 28, 2014 @ 3:26 pm

  2. After looking over a number of the blog posts on your web site, I seriously like your way of
    writing a blog. I book marked it to my bookmark website list and will
    be checking back soon. Please visit my website as well and
    tell me how you feel.

    Comment by Jewell Vaccarella — January 3, 2014 @ 7:21 pm

  3. If some one wishes expert view on the topic of blogging then
    i advise him/her to pay a visit this webpage,
    Keep up the good work.

    Comment by SEO Technology — August 23, 2013 @ 3:26 am

  4. I am really enjoying the theme/design of your weblog.

    Do you ever run into any web browser compatibility problems?
    A couple of my blog visitors have complained about my website
    not working correctly in Explorer but looks great in Safari.
    Do you have any ideas to help fix this problem?

    Comment by Bessie — May 7, 2013 @ 8:43 pm

  5. Surfing around delicious.com I noticed your blog bookmarked as:
    JavaFX as JSF 2.0 VDL | Alexander Smirnov’s personal Weblog. Now I’m
    assuming you book-marked it yourself and wanted to ask if social bookmarking
    gets you a large amount of targeted visitors? I’ve been considering doing some bookmarking for a few of my websites but wasn’t
    certain if it would generate any positive results.
    Thanks.

    Comment by golf app — March 6, 2013 @ 3:39 pm

  6. Good post however I was wondering if you
    could write a litte more on this topic? I’d be very thankful if you could elaborate a little bit further. Thank you!

    Comment by seo consulting services — March 3, 2013 @ 3:46 pm

  7. […] You can read more about JavaFX as JSF VDL for Alex Smirnov’s blog. […]

    Pingback by JavaFX as JSF VDL (View Description Language)? | Maxa Blog — February 11, 2010 @ 5:15 pm

  8. Totally agree with you (That is why i used kind of a FX-Script demo language in the example of the VAST proposal).

    To go from 7/10 to 8.5/10:
    10) Curly-brace language: Most of the time using the same “language” as is used in the ouput is not without its problems (especially xml->xml like for example with facelets), so this is a real advantage in my opinion.
    7) Being able to dynamically create graphics using FX-Script -> SVG/canvas/flash or even JavaFX without “leaving” the language construct, might be attractive too. But I am only willing to give that 0.5 Points 😉

    [qoob]

    Comment by Imre Oßwald — June 12, 2009 @ 5:42 pm

  9. […] Smirnov (creator of Ajax4jsf and from Exadel) wrote a very interesting post on using JavaFX as JSF 2.0 View Description Language (VDL). I think the binding mechanism from […]

    Pingback by JavaFX as JSF 2.0 View Description Language | Maxa Blog — May 28, 2009 @ 10:10 pm


RSS feed for comments on this post. TrackBack URI

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

Create a free website or blog at WordPress.com.

%d bloggers like this: