Welcome!

APIs for the Internet of Things

Max Katz

Subscribe to Max Katz: eMailAlertsEmail Alerts
Get Max Katz via: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn


Related Topics: RIA Developer's Journal

RIA & Ajax: Article

AJAX and Enterprise RIA Tools - JSF, Flex, and JavaFX

Most organizations are delivering or planning to deliver Rich Internet Applications in 2008

It's essential for IT managers to consider and be aware that more than one delivery platform exists today for Rich Internet Applications. Table 1 covers three platforms and their associated technologies.

While the last two approaches still involve the browser as their foundation, each also taps into powerful virtual machines that are installed as plug-ins to deliver even richer applications.

Let's look at the choices.

JavaServer Faces
Let's start with JavaServer Faces. JSF is an open source, component-based user interface Java framework for building pure browser-based applications. JSF is also the standard technology for building Web user interfaces in the Java EE 5 stack. Pure browser-based applications mean that nothing beyond the standard browser is required to run the application. JSF components generate standard HTML markup. JSF provides a declarative approach to designing the UI. JSF components provide all the logic, as well as encapsulated HTML rendering, so the developer can concentrate on building the UI, instead of messing with low-level HTML. Out-of-the-box, JSF provides a basic set of components such as links, buttons, layout, and tables. What's more, the JSF component approach makes it the perfect technology to develop Rich Internet Applications. However, to efficiently deliver a Rich Internet Application, we have to take the component model a step further.

A popular technique for delivering RIA applications inside a Web browser is AJAX. AJAX stands for Asynchronous JavaScript and XML. It is basically a collection of existing technologies for radically changing user experience on the Web. However, manual AJAX development or the utilization of one of the JavaScript libraries is challenging and, ultimately, both are very poor options. With manual development, it's not uncommon to spend a significant amount of time battling JavaScript browser incompatibilities. Finally, and probably most importantly, manual AJAX coding doesn't fit the JSF component model.

: Nevertheless, all is not hopeless. Due to JSFs extensibility and its component approach, combining JSF and AJAX can be done easily. That's where RichFaces comes in. RichFaces is a rich JSF component library that provides a large number of components with AJAX support. Rich components from RichFaces render all the necessary JavaScript to send an AJAX request and, at the same time, know how to partially update a part of a page when a response comes back. IT organizations can add rich functionality without writing any JavaScript code. Developers can again concentrate on UI development instead of low-level AJAX coding and JavaScript debugging (because the components' JavaScript code will have been tested in all the modern browsers).

While JSF and RichFaces are solid tools for building Rich Internet Applications, other alternatives do exist. Enterprise IT managers must understand and be aware that other delivery mediums exist for Rich Internet Applications. First, we have more than just the browser to deliver Rich Internet Applications. It's common today to look at the browser as the only vehicle for delivering Rich Internet Applications, but it isn't the only medium that should be considered.

Let's look at a quick example using JSF and RichFaces components. We are declaratively defining the UI using JSF tags. Declaratively defining the UI is easier and more natural. When this page is processed, UI components on the page will render the necessary HTML and JavaScript to be sent to the browser.

    <h:form>
   <rich:panel>
  <f:facet name="header">RichFaces</f:facet>
  <h:panelGrid>
    <a4j:commandButton value="Hit Me!" actionListener="#{clickBean.count}" reRender="c" />
    <h:outputText id="c" value="Number of hits: #{clickBean.numOfClicks}"/>
    </h:panelGrid>
    </rich:panel>
    </h:form>

The model behind this page is a simple POJO:

public class ClickBean {

     private Integer numOfClicks = 0;

     public Integer getNumOfClicks() {
     return numOfClicks;
     }
     public void setNumOfClicks(Integer numOfClicks) {
     this.numOfClicks = numOfClicks;
     }
     public void count(ActionEvent event) {
     numOfClicks++;
     }
}

And, finally, when the page is run in a Web browser, Figure 1 shows the result.

Note that when clicking the button, only the counter area is updated. We are not reloading the full page.


More Stories By Max Katz

Max Katz heads Developer Relations for Appery.io, a cloud-based mobile app platform. He loves trying out new and cool REST APIs in mobile apps. Max is the author of two books “Practical RichFaces” (Apress 2008, 2011), DZone MVB (Most Valuable Blogger), and is a frequent speaker at developer conferences. You can find out what Max is up to on his blog: http://maxkatz.org and Twitter: @maxkatz.

Comments (2) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
Michael 06/20/08 10:05:46 AM EDT

As Photoshop and Co can export to JavaFX this would be really interesting in Xara 4 , as it is my prefered program. Are there any plugins or is it coming from Xara itself in the near future?

hopefully! I'm interesting too who needs that ....

yours

Michael

Richard Monson-Haefel 05/22/08 10:07:12 AM EDT

I think this article is little more than an advertisement for Exadel which provides a JSF/Ajax solution. Max ignores Silverlight which is clearly an option that deserves attention. In addition, he completely ignores Curl (Note: I work for Curl) which has been used in production by hundreds of enterprise customers for at least five years - far longer than JSF or Flex.

I guess I can understand why the article is so biased, but I wish it could have been more balanced and the agenda more agnostic.

The truth is that JSF is an obsoleet solution. If you are still doing client development using a server-side framework your not taking advantage of the RIA solutions available today. Server-side GUI frameworks are dead. Let them rest in peace.

Richard Monson-Haefel - Curl, Inc.