| By Anil Sharma | Article Rating: |
|
| May 16, 2007 07:15 PM EDT | Reads: |
5,190 |
This content is reprinted from Real-World AJAX: Secrets of the Masters published by SYS-CON Books. To order the entire book now along with companion DVDs for the special pre-order price, click here for more information. Aimed at everyone from enterprise developers to self-taught scripters, Real-World AJAX: Secrets of the Masters is the perfect book for anyone who wants to start developing AJAX applications.
The Web Page as an Application
AJAX is the right technology for a Web-enabled rich user interface (UI). But as with any technology, unstructured software created using it is a recipe for failure. AJAX is a set of powerful and flexible technologies but its disorderly use can result in spaghetti code. If the code isn't structurally sound, the interface it presents to users is unfriendly and non-intuitive, whereas a structurally sound and cohesive system flows smoothly and delights its user. A cohesive and structurally sound UI is also conducive to iterative refinement by its users, enabling a positive feedback loop. It is cost effective, affordable by a small organization and individuals. And it provides a foundation for easily mixing in works of UI designers and artists.
Unfortunately in the past building a structurally sound UI for a complex business application was hard. Developers stumbled on a UI project only to find out that building a structurally sound UI, where a designer's work can be thrown at will, is tough. It soon became a time-consuming and labor-intensive undertaking. To make matters worse, prototyping one or two scenarios often gave a false estimate of the complexity. The real complexity came when a number of scenarios interacted with each other and the UI started to fall apart from a lack of structure. Building a rich UI was notably harder than a static or semi-dynamic Web UI. The aim of this chapter is to demonstrate how AJAX has solved some of the fundamental issues with building rich user interfaces and simplified it. We will demonstrate that it is relatively easier to build a structurally sound and cohesive UI using AJAX as opposed to other rich client technologies such as Swing and WinForms. An AJAX-based UI is well suited for iterative refinement and provides a clean interface for incorporating UI designers and artists' works.
The original title of this chapter was "The Web Page as Application, Maintain Structure and Cohesion of Complex AJAX Pages." Since the business problems people solve using computers are inherently complex, the solutions tend to be complex in spite of the project team's best attempts to keep them simple. Often software system design and implementation becomes incomprehensible. Focusing our attention back on the user interface aspects of a software system, a sound structure is the key to a comprehensible and flexible UI implementation. If we can identify a set of repeatable patterns in user interface software, then it is possible to build relatively simple software even for complex business problems. If so our chapter heading can be "The Web Page as Application: Maintaining Structure and Cohesion of AJAX Pages for Solving Complex Business Problems." The business problem may be complex but the structure of the software doesn't have to be. So here we'll try to describe a structure for AJAX UIs that solves inherently complex business problems but isn't in itself complex.
Having played with AJAX for about a year and having spent many years building UIs using Swing, WinForms, JSF and JSP technologies, there seems to be a light at the end of the tunnel. HTML DOM, CSS, scripting through JavaScript and an XML pipe to the data and services are enough for a flexible, easy-to-use and structurally sound UI framework.
To summarize:
- Business problems are inherently complex with ever-changing requirements.
- A structurally sound and cohesive design leads to an intuitive and delightful UI for solving complex business problems.
- A structurally sound UI is conducive to refinements and artists and UI designers can contribute.
- AJAX has the right ingredients for building a structurally sound and cohesive UI.
The initial sections of this chapter will discuss concepts abstractly. Later sections go into detail about the concepts through examples. The complete code for the examples given here can be downloaded from www.vertexlogic.com. It is available under the MIT open source license.
Assumptions and Guidelines
A brief look at the assumptions made and the guidelines used in the following discussion:
- A rich UI using AJAX doesn't mean popping up multiple property sheets, split panes, and docking windows. At the same time it doesn't preclude any of these constructs if required for the scenario.
- An AJAX UI doesn't mean precluding a page-oriented UI that is successful, easy-to-use and popular in Web applications.
- A rich UI using AJAX is expected to combine the two styles. How much of one over the other depends on the domain.
- An AJAX UI should necessarily lead to higher user productivity and satisfaction.
- We choose to stay within the realm of standard technologies and not introduce entirely new concepts and technologies such as a new tag language.
- We don't use any open or proprietary framework in our examples. The idea is not to introduce readers to a framework but to discuss concepts that provide insight into how a framework works and can be built. Other chapters will cover the available frameworks.
For completeness, the basic workings of an AJAX UI can be described as follows:
- HTML pages with JavaScript code are served to the browser.
- Instead of fetching a new page each time, JavaScript code fetches data from the back-end over HTTP/HTTPS or using Web Services.
- The data is mixed with the HTML document object model (DOM) and the final user views are created in the browser space.
- User interaction is handled using JavaScript code in the browser space. Based on the type of interaction, JavaScript code fetches new data and HTML templates from the back end or updates the UI state locally.
Figure 5.1 shows the architecture of a system that will be used in our discussion. It is generic and something we say will apply to any variation. Even if the architecture is changed, the principles discussed should hold. In the next few sections we'll provide an overview of the components shown in the diagram. These components will be discussed at greater length with example code and illustrations in subsequent sections.
So the architecture can be viewed in two parts:
- Server side
- Client side
The client-side consists of the HTML pages and JavaScript code embedded in the HTML pages or included from separate files. HTML templates and JavaScript files are physically deployed with the server, but they are really a part of the client side. HTML pages and JavaScript code morph into Model, View, and Controller components in the browser space by design intent.
XML over HTTP/HTTPS is used for interfacing between the client and server. It's possible to use Web Services for client/server interaction. But for purposes of the current discussion, we've limited the interface to XML over HTTP/HTTPS. In the example code, we've modularized the client-side implementation of this interface. It can easily be changed to work with Web Services instead of the controller servlet.
This content is reprinted from Real-World AJAX: Secrets of the Masters published by SYS-CON Books. To order the entire book now along with companion DVDs, click here to order.
Published May 16, 2007 Reads 5,190
Copyright © 2007 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Anil Sharma
Anil Sharma is a founder of Vertex Logic and architect of its AjaxFace product. He is working with Vertex Logic's customers and helping them deploy WEB 2.0 applications built using AjaxFace. These applications are in the areas of online printing, community WEB sites and social networking. He is driving future products of Vertex Logic. Prior to Vertex Logic, he was CTO and founder of Softrock Systems and Component Plus. There he built a model driven application platform using J2EE. His primary interests include user interface infrastructures and model driven applications. He is one of the contributors of the book "Real World AJAX - Secrets of the Master".
- Kindle 2 vs Nook
- Cloud Computing on Gartner's Top 10 List and SYS-CON Events' 2010 Calendar
- Confessions of a Ulitzer Addict
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Moving Your RIA Apps into the Cloud: Seven Challenges
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Windows 7 – Microsoft’s First Step to the Cloud
- Ulitzer Provides a Powerful Social Journalism Platform
- Jill Tummler Singer, Deputy CIO of CIA, Keynotes at GovIT Expo
- Open Source Mobile Cloud Sync and Push Email
- Kindle 2 vs Nook
- The Difference Between Web Hosting and Cloud Computing
- Cloud Computing on Gartner's Top 10 List and SYS-CON Events' 2010 Calendar
- Ajax in RichFaces 3.3, JSF 2 and RichFaces 4
- Confessions of a Ulitzer Addict
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- My Thoughts on Ulitzer
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- US Post Office Hops a Ride on NetSuite’s Cloud
- Moving Your RIA Apps into the Cloud: Seven Challenges
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Building a Drag-and-Drop Shopping Cart with AJAX
- What Is AJAX?
- Google Maps! AJAX-Style Web Development Using ASP.NET
- Flashback to January 2006: Exclusive SYS-CON.TV Interviews on "OpenAjax Alliance" Announcement
- AJAXWorld Conference & Expo to Take Place October 2-4, 2006, at the Santa Clara Convention Center, California
- AJAX Sponsor Webcasts Are Now Available at AJAXWorld Website
- How and Why AJAX, Not Java, Became the Favored Technology for Rich Internet Applications
- "Real-World AJAX" One-Day Seminar Arrives in Silicon Valley
- AJAXWorld University Announces AJAX Developer Bootcamp
- AJAX Support In JadeLiquid WebRenderer v3.1
- Where Are RIA Technologies Headed in 2008?
- Struts Validations Framework Using AJAX





































