Let me begin with a story about my friend, a tech lead at a small business company. He was assigned the task of enriching his company's "Expense Claim" application with Ajax technologies. At first, he planned to deliver the application in 3 months, but it wound up taking him 6 months. Here are some "Ajax deadly sins" that delayed his project:

Browser Incompatibility Firstly, he decided to develop in-house JavaScript code for the UI, the 1st draft of which took his team 2 months to finish. Then he discovered that the layout was a mess on different browsers. Due to a lack of JavaScript knowledge, he then decided to adopt an off-the-shelf Ajax widgets framework along with a Java-to-JavaScriptframework in order to overcome this browser incompatibility issue; that, of course, meant re-building the UI from scratch.

Tedious Client-Server Communication CodingJust when it appeared that his team had escaped from the nightmare of JavaScript, there came an even bigger challenge related to integration between the UI and the backend: the Java-to-JavaScript framework required RPC calls to get data from the server and handle the returned data manually. It produced numerous files to communicate between the client and the server. Though developing in pure Java, his team spent a few more months finishing the integration.

Slow PerformanceDuring testing by their users, it was discovered that the performance was unacceptable; users had to wait for more than 10 seconds for 10 thousand records to be loaded. Even worse, some old computers actually stalled. Unfortunately they had to implement load-on-demand to improve the performance issue. But, load-on-demand was never an easy job. It required determining the visible area at the client side, prompting required data from the server side, and the rendering of the data on the browsers. To fulfill this requirement, his team had to delay the project a few additional months.

Maintenance HeadacheLater in the project cycle, he was informed that extra fields would be added to the data model. This was really a nightmare for his team, since they not only had to modify the backend code, but also the associated client code. They spent another month maintaining the consistency of business logic between client and server code. In the end, his team spent 6 months to deliver the "Expense Claim"application.

Trouble Maker: Primitive Programming Model

From my point of view, most of these problems are caused by a primitive programming model which separates the UI and the backend of the applicatio into 2 sides as follows:A two-sided programming model brings a lot of trouble fordevelopers, since they have to take care of the following process-unrelated issues by themselves:

Browser incompatibilityNo longer an issue, solved by any modern Ajax frameworks

Client-server communicationDisplaying data on the client by retrieving data from server

Slow performanceDevelopers tend to put too much data on the client

Business logic inconsistency between clientand serverReplication of business logic on the client

The ideal programming model should save developers from these cumbersome tasks. To resolve all of the above issues at once, the UI and the back-end of an application should never be separated. Instead, they should run on the same side, either the server-side or the client-side.

To improve developer productivity, and provide easier access to server resources, the application should run on the server only. The ideal programming model should look as follows:Developers should simply focus on the business logic of their application, and the rest of the job should be handled by the adopted framework, automatically. As far asI am concerned, the best way to use Ajax is to not even know it exists!

I will refer to this framework as Direct Ajax because the application can access user interfaces, database, and all kinds of resources directly. Direct Ajax provides developers an easier way to create rich internet applications without being bothered by process-unrelated jobs.

Direct Ajax

The architecture of Direct Ajax looks as follows: The UI and the backend of an application are integrated seamlessly, and Direct Ajax is responsible for rendering the content to the client, and automatically synchronizingthe state between client and server.

Direct Programming

Direct programming should fulfil the following three criteria:

Direct UI AccessThe application can get and set valuesfrom UI directly. Here is the pseudo code,

The grid sends the data to the client only if it is visible. It saves a lot of network traffic if the amount of data is huge.

With direct access with UI, database, and live-data, Direct Ajax helps you avoid the following nightmares:

Slow Performance

Tedious Client Server Communication Code

Maintenance Headache

Which Framework to Use (How to do Direct Ajax)

After introducing the benefits of Direct Ajax, I would like to examine currently available Ajax frameworks to determine how many of them satisfy the requirements of Direct Ajax.

A Comparison MatrixIn the above matrix, there are four frameworks that support server-side programming, namely:
ZK,
Backbase,
Echo2, and Icefaces.
ZK, however, surpasses the others with its full support of other features, markup language, scripting language, load-on-demand, and mobile support.

5 Reasons you should use Direct Ajax

Building an enterprise application is never an easy task, not to mention enriching its user experience at the same time. Direct Ajax is designed to help developers deliver the project on time without working over-time. Here are the five reasons you should use Direct Ajax.

Fast Prototyping. The UI, and the backend of an application are no longerseparated.

Quick and Easy Learning. No more JavaScript, XMLHttpRequest.

Secure Communication. No danger of exposure of business logic to theclient, and data over the Internet.

Easy Maintenance. No more client code.

Beyond Direct Ajax (Ubiquitous - mobile)

In addition to the above benefits of Direct Ajax, the extensibility of the application is also quite important. ZK demonstrates its extensibility by extending the Web application to Java Phones and to the Android platform with ease. With ZK, you can run your Web applications almost anywhere.

About Author

Robbie Cheng is a senior engineer at the ZK Team. He develops ZK forum, and ZK extension for Google Android. He is experienced in developing Ajax application. He is also the author of, ZK: Ajax without the Javascript Framework.