JavaScript EditorFreeware JavaScript Editor     Ajax Tutorials 



Main Page

Previous Page
Next Page

Chapter 10: Ajax Frameworks

Overview

In this chapter, you will see three frameworks that all have a common goal: to make the task of developing Ajax-enabled web sites easier and quicker. They all try to abstract the details concerning the underlying communications between the server and the client, leaving the developer free to concentrate on the more interesting aspects, such as implementing the classes that actually take care of the business logic peculiar to an application.

The frameworks chosen each use a different server-side processing technique: PHP, Java, and ASP.NET, respectively. They all fall into the category of frameworks known as Remote Invocation. This means that the framework is responsible only for providing client-side JavaScript that handles the creating of the XmlHttpRequest, converting parameters to a suitable format, and returning values to the page, usually through a callback function. This is in contrast to HTML/JS Generation frameworks, which only require the user to handcraft any customization code but allow less control over the request and response handling.

This chapter focuses on the following three frameworks, among the many available:

The examples for each framework follow a common pattern: each demonstrates how to create a business object and call its methods asynchronously from an HTML client.

Note

The term business object is given to a class that reflects a real-world entity and has the methods and properties necessary to support working with it from within an application. An example would be a Video class used in a video store's booking system. The Video class might have properties such as title and dailyRentalCost, and methods such as isOverdue().

The business object in our examples will represent a customer, a common class in many applications. In a real-life scenario, the Customer class could contain many properties, such as the customer's name, address, and how long he or she had been a client, as well as methods such as getOutstandingOrders().

To make the examples more manageable and allow them to focus on the use of the frameworks, the Customer class used in the examples is much simpler. It has only one method, getAddressFromEmail(), which returns the customer's address given his or her e-mail address as a parameter.

Note

In a well-built application, the business classes, representing real-world entities, are separate from the data classes, which deal with persisting the details to a permanent storage facility, such as a relational database. To keep the examples straightforward, the Customer class itself will handle retrieving information from the database.


Previous Page
Next Page




JavaScript EditorAjax Editor     Ajax Validator


©