Contents
What is Ajax? Ajax, which is growing rapidly in popularity, is a technique for creating improved web browser user interfaces for a web application. It is becoming so widely used that you probably have seen Ajax at web sites you have accessed, perhaps without even realizing it. Ajax can help increase the speed and usability of an application's web pages by updating only part of the page at a time, rather than requiring the entire page to be reloaded after a user-initiated change. Furthermore, Ajax uses capabilities already present in modern web browsers and does not require any plug-ins. To better understand Ajax, let's look at a simple example of a web application that includes Ajax and then compare it with HTML and DHTML. Google(TM) Suggest is a good example of a simple web application using Ajax. See Figure 1.
Here's how this application works. As you type data into an input field, Google offers suggestions to complete the input in a short list that appears below the entry field. For example, in Figure 1, we have typed the letters "aja" and the application continuously updates the suggested list of choices based on what we've typed. In addition to presenting a list of possible entries that complete the input, Google also suggests "ajax" as the most likely choice, pre-types the last part of the string (the "x") in the entry field, and places this choice at the top of the list. If "ajax" is the entry we want, we can simply press the enter key to Google's entry "ajax" without typing the entire string. Suppose instead we wanted Google's suggested "ajanta caves". We can use the down arrow to move to "ajanta caves" and, when highlighted, press the enter key or use the mouse to click that selection. A third option is to continue typing: Google continuously updates the suggestions based on what we type. Google Suggest accomplishes these improvements in the web browser interface using a technique call Ajax. To better understand what Ajax is, let's first compare it with two other web page techniques, HTML and DHTML. Ajax and HTML
In this HTML-only mockup, the user could click the Suggest button to display a new web page with a list of suggestions. However, the Ajax user interface we just described offers two improvements over the HTML-only mockup:
In summary, web application developers are excited about Ajax because it provides a technique that saves users time and simplifies the user interface compared with a non-Ajax HTML application. Ajax and DHTML In summary, web application developers are also excited about Ajax is because it allows DHTML-like interactive web page techniques to be used with data requested from the server after user interactions with the page. Ajax Technical Overview There are many different tools and technologies for building web application including Java Studio Creator, PHP, J2EE, Ruby on Rails, DotNet, and others. Ajax can be used by all these communities because an Ajax web application only requires a modern web browser. Ajax is not tied to any specific tool, web application framework, or industry vendor. For these reasons a broad range of communities have an active interest in using Ajax. Let's now take a more technical look at Ajax. First let's dive right in with a look at the steps to using Ajax in a web application. Figure 3 shows the processing steps taken over time, from the user, browser, and server perspectives, for a web application with Ajax. The steps are numbered according to their sequence in time, with time increasing from top to bottom in the table.
These steps correspond to a scenario such as the one described for Google Suggest. They show how processing moves in a defined sequence among the server, browser, and user. Let's walk through these steps in the order they occur.
Summary: What is Ajax?
Ajax and Sun Java Studio Creator 2 In a JavaOne 2005 keynote demo, Tor Norbye built, deployed, and demonstrated in a browser a Google Suggest-like web application in just three minutes time. Tor was able to work so quickly because he used the Sun Java Studio Creator 2 IDE with an associated Ajax-enabled text completion component. The Java Studio Creator IDE's components/properties/events approach for developing web applications is well matched for Ajax. Java Studio Creator 2 is accompanied by components with improved user interfaces via DHTML functionality. These DHTML components generate JavaScript running in the web browser, which generally saves you from the need to implement and test JavaScript yourself. Component properties let you customize the appearance and behavior of a component, including aspects implemented in DHTML. Events let you easily write server application code for the component. Tor's demo showed that it is possible to build a web application with Ajax user interface improvements using Java Studio Creator 2 and its component-based approach to web application development. An Ajax component includes the JavaScript that runs in the browser to process user inputs, request data from the web server, and update the web page based on the server response. (This functionality is discussed in steps 4 through 7 in the technical overview section.) An Ajax component can save you from the need to develop JavaScript in the same way that components provided with Java Studio Creator today can save you from the need to implement JavaScript and DHTML. To help you see how this works, we're releasing an add-on component library as an update to Java Studio Creator 2 that allows you to use a variety of sample Ajax components. (These components are the BluePrints Ajax components.) The Sample Ajax Components article walks you through the samples and helps you learn more. Like non-Ajax components, when an Ajax component is enhanced to support Java Studio Creator 2, you can efficiently build a web application using the Ajax component. One interesting thing the samples show is how easily an event handler in the IDE can process the asynchronous Ajax request. In Java Studio Creator 2, you may simply write an event handler that returns a result as described in steps 4 through 7. The IDE makes this extremely easy: when you are ready to write the event handler, double click the component and the IDE opens the Java source code to the event handler method template it has just created. While Tor's example showed a component making a web service request, in general, an Ajax event handler can perform processing that does not require a web service. For example, an Ajax event handler can perform a database query and return results from the query. Regardless of the form of an Ajax request, the server processing and browser user interface design should together ensure a responsive user interface. Also, the Ajax event handler has all the flexibility and power of JavaServer Faces event handlers, including binding Ajax request events to properties, which we mention in the Sample Ajax Components article. Ajax components also can have properties that may be used in the Ajax processing on the client and/or server side. For example, one of the samples includes properties that are used as parameters for a Google Maps display request. The IDE makes it easy to set these properties, just like for other non-Ajax components. Summary: Ajax and Java Studio Creator
Digging Deeper Things You Can Do Sequence Diagram Table 1 gives the text equivalent for the steps shown in Figure 3. Table 1. Web Application with Ajax Processing: Steps Over Time
Return to the Sun Java Studio Creator developer resources pages. |
Find out more about Java Studio Creator and Ajax on our Ajax page
See a screencast demo by Ed Burns (co-spec lead for JavaServer Faces) of the Ajax components available inside Java Studio Creator.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Oracle is reviewing the Sun product roadmap and will provide guidance to customers in accordance with Oracle's standard product communication policies. Any resulting features and timing of release of such features as determined by Oracle's review of roadmaps, are at the sole discretion of Oracle. All product roadmap information, whether communicated by Sun Microsystems or by Oracle, does not represent a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. It is intended for information purposes only, and may not be incorporated into any contract.
|
| ||||||||||||