Summary
Ajax4JSF is an open-source java.net project that aims to bring Ajax functionality to JSF components. Artima spoke about the project, and about synergies between JSF and Ajax, with Max Katz, an Ajax4JSF committer and a senior engineer with Exadel, the project's main supporter.
Advertisement
Ajax4JSF is a new open-source JSF component framework hosted on java.net. The project recently reached its 1.0 milestone release. Artima spoke with Ajax4JSF committer Max Katz, who is also a senior engineer with Exadel, the project's main sponsor and contributor.
Frank Sommers: What's Ajax4JSF, and how does it help enterprise developers?
Max Katz: The goal of Ajax4JSF is to bring Ajax functionality to Java Server Faces. It's a rich-component framework that provides Ajax capabilities in the form of a JSF component library. At the end of the day, it allows developers to create interactive Web applications that can be developed entirely within the JSF model.
We see JSF becoming the standard for building enterprise Web applications. There is now a huge momentum behind JSF. About a year and a half ago much development focused around Struts, but that is now moving to JSF. And JSF has become a standard, as part of Java EE 5, whereas many of the other Java enterprise frameworks are not [based on] standards.
Even with the many Web frameworks in use over the past several years, those frameworks mostly tried to ease development on the server-side. The client-side has remained fairly static. JSF is a step forward in the development of frameworks but, by itself, JSF does not address the client-side of a Web application. Ajax fills that need, because it promises to give Web application users desktop-like experience on the client. Ajax4JSF aims to combine the server-side model of JSF with Ajax to give you the best of both the server-side and client-side worlds.
Frank Sommers: Do you see a synergy between JSF and Ajax, or do these technologies merely complement one another?
Max Katz: There's a lot of synergy. To start with the user experience, consider that many Web applications include drop-down boxes in the user interface. When you select an item in that box, you want some other parts of the UI to update based on the selection value. A traditional Web application would have you submit the page, and process that selection on the server, and then return a new page with data based on the selection. But that selection is really just a user interface gesture, and Ajax allows you to keep that interaction on the client, re-rendering only the changed component. Under the covers, the selection still triggers some server-side action to get the new data, but the user is not aware of that. So that drop-down component, which can be a JSF component, now provides greater usability.
From the programmer's point, you could achieve that sort of interactivity using only JavaScript on the client. But then you're developing on a low level, and that's not only tedious but is also very error-prone, and you'd quickly get into the murky issue of browser-compatibility. JSF gives you a much higher abstraction layer. JSF allows you to code up this interaction in a component model, which hides a lot of the low-level details.
In JSF, you develop your entire application out of user interface components. For instance, you simply specify a JSF component for that drop-down list, and nest it somewhere in your component hierarchy, setting perhaps a few attributes on that component. You're not dealing with markup any more. You're dealing with components that render a drop-down list or a table.
Rendering an Ajax4JSF component renders a lot of JavaScript to the client. But you don't deal with that JavaScript, and we [the Ajax4JSF project] test that JavaScript, so you don't really have to worry about testing it in various browsers. We follow the standard JSF rendering mechanism in rendering an Ajax4JSF component, and the JavaScript is just part of that component's rendering.
In fact, were you to use client-side JavaScript while trying to use JSF, you'd really be breaking out of the component model. When you're developing with JSF, you should stay in the JSF component model. There is no good integration [currently] for hand-written client-side JavaScript and JSF components, or even between some of the pure JavaScript client frameworks and JSF. With JSF, you get the benefits of many tools that support the framework, and also share some of the benefits from JSF being part of Java EE 5 now—JSF integrates nicely with other parts of EE. Plus, you should remember that, as a component framework, JSF is extensible, so you have a lot of freedom in what you do even within the JSF model.
The biggest benefit of adding Ajax at the component level is that if you already have a working JSF application, and then want to add more interactivity to that application, you don't need to change your application. Simply add a few Ajax4JSF components, substituting existing components perhaps, to provide that Ajax functionality on your page.
Frank Sommers: What sets Ajax4JSF apart from some of the other Ajax-aware JSF libraries?
Max Katz: Since the Ajax4JSF library is a JSF component library, it fully integrates with the JSF lifecycle. There are other frameworks that only integrate with lifecycles of managed beans, for instance. Another thing to note is that Ajax4JSF is an open architecture based on the JSF standards. We didn’t want to change how people work with JSF, only wanted to help solve the problem of making JSF applications more interactive.
As a result, Ajax4JSF components work well with other JSF components, even with your own custom components. That's because we take advantage of the ID attribute in each JSF component. As long as a component has an ID, which is required by JSF, you simply specify to an Ajax4JSF component what other components to re-render [as a result of some user action or server-side event]. The main benefit of that is that you can incrementally add Ajax functionality to a JSF application, and you don't need to think of Ajax-enabling a JSF application as something special—it's just a matter of substituting Ajax4JSF components for some of your non Ajax-enabled components.
Frank Sommers: How many developers or projects are you aware of that currently use Ajax4JSF?
Max Katz: I don't know the number of users, but the project has been available on Java.net since early May under the Common Development and Distribution License. There is now an active mailing list. We were really surprised that after [Exadel] made the project open-source, we received lots of feedback, and the community has helped us make the code a lot more stable.