You are previewing Ajax on Java.
O'Reilly logo
Ajax on Java

Book Description

This practical guide shows you how to make your Java webapplications more responsive and dynamic by incorporating newAjaxian features, including suggestion lists, drag-and-drop, andmore. Java developers can choose between many different ways ofincorporating Ajax, from building JavaScript into your applications"by hand" to using the new Google Web Toolkit (GWT).

Ajax on Java starts with an introduction to Ajax,showing you how to write some basic applications that useclient-side JavaScript to request information from a Java servletand display it without doing a full page reload. It also presentsseveral strategies for communicating between the client and theserver, including sending raw data, and using XML or JSON(JavaScript Object Notation) for sending more complex collectionsof data.

The book then branches out into different approaches forincorporating Ajax, which include:

  • The Prototype and script.aculo.us Javascript libraries, theDojo and Rico libraries, and DWR

  • Integrating Ajax into Java ServerPages (JSP) applications

  • Using Ajax with Struts

  • Integrating Ajax into Java ServerFaces (JSF) applications

  • Using Google's GWT, which offers a pure Java approach todeveloping web applications: your client-side components arewritten in Java, and compiled into HTML and JavaScript

  • Ajax gives web developers the ability to build applications thatare more interactive, more dynamic, more exciting and enjoyable foryour users. If you're a Java developer and haven't tried Ajax, butwould like to get started, this book is essential. Your users willbe grateful.

    Table of Contents

    1. Ajax on Java
      1. SPECIAL OFFER: Upgrade this ebook with O’Reilly
      2. A Note Regarding Supplemental Files
      3. Preface
        1. Ajax: Some History
        2. Audience
        3. Assumptions This Book Makes
        4. Contents of This Book
        5. Conventions Used in This Book
        6. Using Code Examples
        7. How to Contact Us
        8. Safari® Enabled
        9. Acknowledgments
      4. 1. Setup
        1. 1.1. Requirements
        2. 1.2. Installing Tomcat
          1. 1.2.1. A Minimalist Guide to Setting Up Tomcat
          2. 1.2.2. Setting TOMCAT_HOME
        3. 1.3. Installing Ant
      5. 2. JavaScript for Ajax
        1. 2.1. Creating the Application
          1. 2.1.1. How Is Our JavaScript Function Called?
          2. 2.1.2. How Do We Get the Value of the Key Pressed?
          3. 2.1.3. Formatting the Page
        2. 2.2. Running the Example
      6. 3. A Simple Ajax Servlet
        1. 3.1. Building and Deploying the Ajax Application
          1. 3.1.1. Directory Structure
        2. 3.2. Running the Example
          1. 3.2.1. So Where's the XML?
      7. 4. XML and JSON for Ajax
        1. 4.1. The Character Decoder
        2. 4.2. Setting Up a Simple XML Document
          1. 4.2.1. Using a Servlet to Build an XML Document
          2. 4.2.2. Other Ways to Build the XML Document
            1. 4.2.2.1. JDOM
            2. 4.2.2.2. dom4j
            3. 4.2.2.3. SAX
        3. 4.3. Back on the Client: Mining the XML
          1. 4.3.1. XML Parsing with JavaScript
          2. 4.3.2. Populating the Form on a Microsoft Browser
          3. 4.3.3. Populating the Form on Other Browsers
        4. 4.4. Building the Application
        5. 4.5. Running the Application on Tomcat
        6. 4.6. Passing Data with JSON
          1. 4.6.1. Changing the JavaScript for JSON
        7. 4.7. Summary
      8. 5. Getting Useful Data
        1. 5.1. Form Entry with Ajax
          1. 5.1.1. Validating the Username
          2. 5.1.2. Creating the Database
          3. 5.1.3. Servicing the Ajax Request: Servlets
          4. 5.1.4. Loading City and State by Zip Code
        2. 5.2. Building a Suggestion Field
          1. 5.2.1. Retrieving the Usernames
          2. 5.2.2. Creating the Div
          3. 5.2.3. Handling the Events
            1. 5.2.3.1. Highlighting a suggestion
          4. 5.2.4. Configuring the Servlets
      9. 6. Ajax Libraries and Toolkits
        1. 6.1. Using the Dojo Toolkit
        2. 6.2. Using the Rico Toolkit
          1. 6.2.1. Using Rico's Object Response Type
        3. 6.3. Using DWR with Ajax
        4. 6.4. Drag 'n' Drop with Scriptaculous and Prototype
          1. 6.4.1. The User Signup Application
          2. 6.4.2. Using Prototype to Wrap XMLHttpRequest
          3. 6.4.3. The User Login Functions
          4. 6.4.4. The Shopping Functions: Getting a Product List
      10. 7. Ajax Tags
        1. 7.1. Creating a Tag Library
          1. 7.1.1. Writing a TLD
          2. 7.1.2. Using the Tags in a JSP
          3. 7.1.3. Writing the TagSupport Class
          4. 7.1.4. Writing the Support Servlet
          5. 7.1.5. Using Ant to Put It All Together
        2. 7.2. Third-Party Tag Libraries
          1. 7.2.1. AjaxTags
            1. 7.2.1.1. Getting and installing AjaxTags
            2. 7.2.1.2. Using the <tabPanel> tag
            3. 7.2.1.3. Writing the servlet code
            4. 7.2.1.4. Displaying data in the tabs
          2. 7.2.2. JavaWebParts
          3. 7.2.3. AjaxAnywhere
            1. 7.2.3.1. Enabling AjaxAnywhere in the JSP
            2. 7.2.3.2. Refresh zones
            3. 7.2.3.3. Writing support for AjaxAnywhere
            4. 7.2.3.4. The AjaxAnywhere filter
          4. 7.2.4. Which Tag Library Should I Use?
      11. 8. Ajax on Struts
        1. 8.1. Struts-Layout
          1. 8.1.1. Installing Struts-Layout
          2. 8.1.2. Writing the Struts-Layout JSP
          3. 8.1.3. Struts Action Forms
          4. 8.1.4. What's an Action, and What Happened to My Servlet?
          5. 8.1.5. The Struts Configuration
          6. 8.1.6. Where Does the Data Come From?
          7. 8.1.7. Populating the Suggestion List
          8. 8.1.8. Struts-Layout Is Cool Because...
        2. 8.2. Adding Ajax to Struts with DWR
          1. 8.2.1. Uploading Files
          2. 8.2.2. Creating the JSP
          3. 8.2.3. Writing the DWR Configuration File
          4. 8.2.4. Displaying the Products in the Browser
          5. 8.2.5. Viewing the DWR-Generated JavaScript
          6. 8.2.6. Writing the ProductManager Class
          7. 8.2.7. DWR Is Cool Because...
        3. 8.3. Ajax with Struts: What Have We Learned Here?
      12. 9. JavaServer Faces and Ajax
        1. 9.1. The JSF Lifecycle
        2. 9.2. Writing a Custom JSF Component
          1. 9.2.1. Writing the JSP Page for the JSF Application
          2. 9.2.2. Configuring JSF: web.xml and faces-config.xml
        3. 9.3. Developing a Custom JSF Tag
          1. 9.3.1. Writing the TLD File
          2. 9.3.2. Writing the Tag Handler
          3. 9.3.3. Creating a Renderer and Render Kits
          4. 9.3.4. Writing the JavaScript Support File
        4. 9.4. Handling JSF Input by Extending HtmlInputText
        5. 9.5. Writing the JSF Support for Ajax
        6. 9.6. Summary
      13. 10. Google Web Toolkit
        1. 10.1. Getting Started with GWT
          1. 10.1.1. Hosted Mode Versus Web Mode
        2. 10.2. Debugging the Application
        3. 10.3. Fleshing Out the Application: The Client
          1. 10.3.1. Customizing the Client
        4. 10.4. Supplying Services to the Client
          1. 10.4.1. Connecting the Client to the Service
          2. 10.4.2. Connecting the Service to the Servlet URL
        5. 10.5. Testing ZipCodes with the Service
        6. 10.6. GWT Widgets
      14. Index
      15. About the Author
      16. Colophon
      17. SPECIAL OFFER: Upgrade this ebook with O’Reilly