Evolution of Web Applications
The web browser has become a primary vehicle for delivering business applications to users. There are several benefits to delivering software through the web, including easy administration and simplified accessibility. For all these benefits, however, web applications typically exhibit limited functionality when compared to thick client software. Not only is usability diminished, developing these web applications is often more complex than writing for the desktop, mainly due to the stateless nature of HTTP. Not long after the advent of the web, developers began seeking ways to make their web sites mimic the look and responsiveness of desktop applications. This was often be a dangerous proposition because doing so typically required complex client side programming with JavaScript. Recently, the promise of Ajax technology has given web developers new hope. This article will introduce the open-source Ajax framework known as ZK that allows Java developers to create rich web applications.
Ajax (Asynchronous JavaScript and XML) technology relies on asynchronous communication between client and server to provide users with a dynamic and responsive interface. In traditional Java Servlet-based web applications, a page’s entire content is sent via a request to the server where a response is generated and returned. When the client receives this response, the complete page is rendered back to the user. This is the case even if a specific request is relevant to only a small portion of the page. In this scenario, given the amount of processing involved from request to response, contact with the server is kept to a minimum. With Ajax, several light weight requests are continuously sent to the server and responses to those requests cause a partial rendering of the page’s model. Server requests are more frequent in nature, but they also tend to be smaller and less expensive. Developing Ajax applications can be a costly enterprise if it means adding significant amounts of JavaScript code. Client script can be difficult to write and maintain, largely due to the fact that different browsers support different implementations of JavaScript and these issues must be addressed by the developer.
ZK Framework Overview
ZK is an AJAX-based web framework from the Potix Corporation. ZK is open-source, licensed under the GPL (GNU Public License). ZK’s AJAX engine consists of both client and server components that communicate with one another. ZK provides two sets of user interface components. One set of components is based upon XUL, or the XML User Interface Language. The second set utilizes XHTML. ZK provides an XML-based markup language called ZUML for adding components to a page. Though ZK’s Ajax engine makes considerable use of JavaScript, it is important to note that the complexity of implementing Ajax is concealed from the developer. Client side events send data to the server where the developer can handle them with Java code. ZK provides a simplified programming model, similar in many respects to programming with Java Swing. In the Model-View-Controller architecture, ZK addresses the ‘View’ portion of an application. Developers are free to use technologies such as Enterprise JavaBeans and object-relational frameworks such as Hibernate in conjunction with ZK. It is even possible to incorporate ZK into applications that use view technologies such as JavaServer Pages and JavaServer Faces.
In the remainder of this article, we will take a brief look at ZK in action. The sample application presented here is by no means a comprehensive demonstration of ZK’s features. Hopefully, it will encourage you to explore the framework yourself in greater detail.
ZK in Action
The sample application allows university students to create a schedule of courses. There are several domain objects used to represent data used by the application:
Java Class | Description |
Course | Subject offered at university |
Room | Room on university campus |
Faculty | Instructor at university |
AvailableCourse | Course that student may schedule |
Student | Student at university |
StudentCourse | Course in student’s schedule |