New Technologies for Ajax and Web Application Development: Project jMaki, Project Dynamic Faces, and Project Phobos

   
By Jennifer Ball, October 2006  

Articles Index

This is the first in a series of introductory articles about new projects that make developing interactive and dynamic web applications easier. Project jMaki and Project Dynamic Faces make it easier to add Ajax functionality -- a technology that includes but is not limited to Asynchronous JavaScript and XML -- to your web applications. The Phobos project allows you to develop web applications using a scripting language, which can allow for more rapid development.

Meeting the Demand for Interactive, Dynamic Web Applications

We're all familiar with using the traditional web application: Fill in some data, click a button, and then wait for something to happen. These days, users of web sites no longer accept this kind of interruption in their workflow. They expect a web application to work with them, to respond immediately to any action they take.

Web application developers have been trying to quickly adapt to meet this new demand for more interactive and dynamic web applications. And many of them are using Ajax to achieve this goal. The Ajax technique uses JavaScript technology to respond to a user's action on a widget. It uses an XMLHttpRequest object to asynchronously exchange XML data between the client and the server and to asynchronously update part of the HTML Document Object Model (DOM) that represents the page with the XML data. If you're not familiar with Ajax, see Greg Murray's introduction to Ajax.

Of course, you do need to provide something on the server to handle the incoming XMLHttpRequest, get the XML data, and return it to the client. As with any web application, your application must be able to handle conversion, validation, data persistence, and navigation. Just throwing some Ajax technology into a web application is not enough. You must be sure that you are doing it right and following recommended design patterns.

Even if you don't follow recommended practices, you can build a web application that initially looks fine. But a poorly built application will quickly show problems of maintenance and scalability.

With Ajax, you can decide which tools and technologies to use to properly develop Ajax-enabled applications. All you need to run an Ajax application is a browser that supports JavaScript technology, as most browsers in use today do. To develop your Ajax-enabled web application, you can use the Java Platform, Enterprise Edition (Java EE), some other development platform, or one of the many scripting languages. You can even use scripting with the Java EE platform. Let's take a look at the relative benefits of the Java EE platform and scripting and the advantage of using them together.

The Java EE Platform and Ajax

Using Java EE platform tools and technologies to build Ajax-enabled applications gives your application access to the entire Java EE platform stack, including new and updated web services and database access technologies. In the stack's web tier, you get Servlets, JavaServer Pages (JSP) technology, and Java Standard Tag Library (JSTL). You also get JavaServer Faces technology 1.2, a framework for building rich user interfaces (UIs) for web applications. It offers a sophisticated, extensible component model for handling events, converting and validating data, and managing component state. In addition, it has a navigation model for handling page flow and a managed bean facility for binding components to scoped beans.

In addition to giving you the extra server-side functionality you need for Ajax, JavaServer Faces technology makes it easy for you to add Ajax to your application. Instead of embedding the JavaScript technology directly in the page, you can encapsulate it inside of a JavaServer Faces component, thereby leveraging all the benefits that the JavaServer Faces component model gives you.

If are using JSP technology without JavaServer Faces technology, you can also encapsulate Ajax functionality using custom tags. Coupled with the rest of the Java EE platform stack, the JSP and JavaServer Faces technologies give you everything you need to complete the server-side picture of your Ajax-enabled web application.

Using Dynamic Languages for Web Application Development

In spite of all the benefits of using the Java programming language, in which all Java EE platform components are written, a growing number of developers prefer scripting languages because they allow for more rapid development. When developers are scrambling to add Ajax functionality to their web applications, they cannot ignore the value of the rapid development that scripting languages offer.

One of the features of scripting languages that foster rapid development is dynamic typing. Because of the dynamically typed nature of scripting languages, developers find that these languages are better for building rapidly evolving systems, connecting different components, and extending existing software components. In part because of this dynamic typing, developers discover that they can often write fewer lines of code when programming with dynamic languages.

Another characteristic of scripting languages is that they do not require a separate compilation step. This allows developers to deploy an application without compiling it and further allows them to manipulate the code while it is running without having to redeploy it.

If you are developing Ajax-enabled applications, you also have the benefit of using the same scripting language on the client and the server if you use JavaScript technology on the server side. And because scripting languages are good for connecting and extending existing components, scripting can be a good match for those developers who want to add Ajax to existing applications.

The Best of Both Worlds: Using the Java EE Platform and Dynamic Languages Together

Although the characteristics of dynamic languages can provide advantages in some situations, they may come at a high cost in others. Because of dynamic typing, a developer trying to read another developer's scripting code might find the code difficult to decipher. In most cases, you would have to execute the code to see what it does and understand it.

Another problem is that developers can experience reduced execution speed as a result of the additional runtime checks they need to perform because there is no compilation step, which would normally catch many of the errors in the code. More importantly, when building more robust applications, developers prefer to catch as many errors as possible during compile time rather than at runtime. This is where a statically typed system language such as the Java programming language comes in.

You can use the Java programming language for those parts of the application that change less frequently, such as graphical user interface (GUI) components, and for those parts of the application that represent a performance bottleneck, such as methods that perform complex calculations or manipulate large amounts of data. And you can use scripting to connect these parts of an application.

New Web Application Development Initiatives: jMaki, Dynamic Faces, and Phobos

Sun is now developing a new framework, code-named Project Phobos, that enables you to develop web applications using a scripting language but also allows you to call in to the Java EE platform stack from these applications to handle those tasks that Java technology components can more appropriately perform.

Sun also offers two new technologies to make it easy to add Ajax to your applications. These two technologies are Project jMaki and Project Dynamic Faces.

The jMaki project allows you to wrap off-the-shelf Ajax-enabled widgets, such as those from the Dojo toolkit or the Yahoo widgets, in a JavaServer Faces component or a JSP tag handler.

Dynamic Faces extends the JavaServer Faces 1.2 runtime to expose the JavaServer Faces life cycle to the web browser, enabling innovative features such as rendering of a partial or a full page through the use of Ajax, dispatching real JavaServer Faces technology events from JavaScript technology, and allowing page authors to identify which existing components on a page are Ajax-enabled.

This is the first in a series of articles that describes in more detail what Phobos, jMaki, and Dynamic Faces are and how to use them in your applications. It also shows how you can use them together. The next article in the series describes the jMaki project.

For More Information

JavaScript Technology
JavaServer Pages (JSP) Technology
Java Standard Tag Library (JSTL)
JavaServer Faces Technology
Project Phobos
Project jMaki
Project Dynamic Faces
Dojo Toolkit

About the Author

Jennifer Ball is a staff writer at Sun. She writes about web application technologies that are part of the Java EE platform.

Rate and Review
Tell us what you think of the content of this page.
Excellent   Good   Fair   Poor  
Comments:
Your email address (no reply is possible without an address):
Sun Privacy Policy

Note: We are not able to respond to all submitted comments.