AJAX Examples (as ready to open NetBeans projects)

Sang Shin, sang.shin@sun.com, Sun Microsystems, www.javapassion.com


This hands-on lab lists AJAX example applications whose source codes are available from the web.  Some of the sample applications are in NetBeans-ready format, meaning you can just open it from the NetBeans and build and run it.  If you are writing a new AJAX application, please see if you can copy an existing NetBeans project from these examples.  These examples can be reference point for your AJAX development.  Some of the example codes deal with advanced topics.  Please use them as a reference.

Expected duration: 180 minutes

Prerequisites

This hands-on lab assumes you have some basic knowledge of, or programming experience with, the following technologies.

Software Needed

Before you begin, you need to install the following software on your computer. 


OS platforms you can use


Change Log


Lab Exercises




Exercise 1: Build, run various AJAX sample applications from "Foundations of AJAX" book

In this exercise, you will build and run AJAX sample applications from the "Foundations of AJAX" book. The goal of this exercise is to get yourself exposed to various other AJAX applications that use XMLHttpRequest.  Please do some experimentation of your own by modifying the code.  The sample applications in this book come with NetBeans project files so you will be able to build and run them as NetBeans projects. 

Due to the copyright reason, the sample code zip file is not included as part of this lab, which means you will have to download the sample code zip file yourself.  If you want to have more detailed explanation on these example codes, you might want to considering purchasing the book.

(1.1) Download and unzip the sample code zip file

1. Download the NetBeans ready sample projects and unzip it in a directory of your choice - it will be called <UNZIP_DIRECTORY>.

2. Under foundations-of-ajax-examples directory, there Chapter02, Chapter03, Chapter04, and Chapter05 directories.  These directories contain ready-to-build NetBeans projects. 

(1.2) Build and run sample applications using NetBeans

1. Open Chapter02 NetBeans project.

2. Build and run the project. Review the source codes. 
3. Repeat the process for Chapter03, Chapter04, and Chapter05 projects.

                                                                                                                     return to the top


Exercise 2: Browse AJAX sample application code from "Pro AJAX and Java Frameworks" book

In this exercise, you will build and run AJAX sample applications from the "Pro AJAX and Java Frameworks" book written by Nathaniel Schutta and Ryan Asles and published by Apress. This book covers advanced topics of AJAX including how to use Web application frameworks with AJAX.    The following is quoted from the apress website. Please see the table of contents.

As a Java developer, you want a guide that shows you how to add Ajax functionality to your web applications with a minimum of effort. Well look no further than Pro Ajax and Java Frameworks. In this book, recognized Java experts and authors of the best-selling Apress title, Foundations of Ajax, will show you how.

The authors begin by recapping Ajax basics. Then they unveil a comprehensive Java/Ajax toolkit. Tools include JSEclipse for code editing, Venkman for JavaScript debugging, and Dojo Compressor for code compression. They also explain Log4js (and other tools) for JavaScript logging, JsUnit (and others) for testing, and various libraries like AjaxTags, DWR, and Script.aculo.us for rapid code development.

The last part of the book shows you how to build up a series of professional Java/Ajax applications. These will incorporate some of today’s most popular frameworks—Spring, JSF, Struts, and Tapestry—giving you all you need to incorporate Ajax into your everyday work and become an Ajax expert!

Please do some experimentation of your own by modifying the code.  The sample applications in this book come with NetBeans project files so you will be able to build and run them as NetBeans projects. 

Due to the copyright reason, the sample code zip file is not included as part of this lab, which means you will have to download the sample code zip file yourself.  If you want to have more detailed explanation on these example codes, you might want to considering purchasing the book.

(2.1) Download and unzip the sample code zip file

1. Download the NetBeans ready sample projects (Pro_Ajax_and_Java_Frameworks-2927.zip, 47M bytes) and unzip it in a directory of your choice - it will be called <UNZIP_DIRECTORY>. 

2. Under pro-ajax-and-java-examples directory, you will see several directories.  These directories contain ready-to-build NetBeans projects. 

(2.2) Build and run sample applications using NetBeans

1. Open Chapter02 NetBeans project.

2. Build and run the project. Review the source codes. 
3. Repeat the process for other projects.

Exercise 3: Browse AJAX sample application code from "Pragmatic AJAX" book


In this exercise, you will build and run AJAX sample applications from the "Pragmatic AJAX book".  The exercises are not NetBeans ready so you would have to rebuild them as NetBeans projects.  At least you should be able to browse the code.

If you want to have more detailed explanation on these example codes, you might want to considering purchasing the book.

(3.1) Download and unzip the sample code zip file


1. Create a directory called pragmaticajax.
2. Download the NetBeans ready sample projects and unzip it under pragmaticajax directory.

(3.2) Explore the code using NetBeans


1. Open NetBeans project.

2. Build and run the project. Review the source codes. 

                                                                                                                     return to the top

Exercise 4: Practical Ajax Projects with Java Technology - optional

In this exercise, you will build and run AJAX sample applications from the "Practical Ajax Projects with Java Technology" book written by Frank W. Zammetti and published by Apress. This book shows how to build real-life and practical Ajax applications. The following is quoted from the apress website. Please see the table of contents.

If you’re a Java developer already versed in Ajax-style programming, and you want to take your knowledge to the next level, then this is the book for you. Practical Ajax Projects with Java Technology provides the ultimate learn-by-example experience, featuring seven complete example applications for you to learn from and then adapt for use in your own projects. During each application, the author will lead you through the planning, design, and implementation stages.

The book begins with a few quick chapters to recap Ajax basics and build up a complete development environment, and then moves on to the applications. The seven applications are diverse: an auto-complete application, an Ajax game, a two-way chat application, a webmail client, an RSS aggregator, an online calendaring/scheduling system, and a Flickr-style photo gallery application. Technologies covered include Apache, Ant, Ajax Tags, Struts, Prototype, DWR, Dojo, and more. Overall, this book will save you countless hours of development time, and help further your Java Ajax knowledge!

Due to the copyright reason, the sample code zip file is not included as part of this lab, which means you will have to download the sample code zip file yourself.  If you want to have more detailed explanation on these example codes, you might want to considering purchasing the book.



(4.1) Download and unzip the sample code zip file


1. Download the sample code zip file (Practical_Ajax_Projects_with_Java_Technology-2931.zip, 29M bytes) and unzip it in a directory of your choice - it will be called <UNZIP_DIRECTORY>.  If you unzipped the file in the C:\ directory on Windows platform, the <UNZIP_DIRECTORY> is C:\.  A subdirectory called 1590596951 gets created under <UNZIP_DIRECTORY>.




                                                                                                                    return to the top

Exercise 5: Pro JSF and AJAX - optional

In this exercise, you will build and run AJAX sample applications from the "Pro JSF and Ajax: Building Rich Internet Components" book written by John R. Fallows and Jonas Jacobi and published by Apress. This book shows how to build real-life and practical Ajax applications. The following is quoted from the apress website. Please see the table of contents.

Pro JSF and Ajax shows you how to leverage the full potential of JavaServer Faces (JSF) and Ajax. This is not an entry-level tutorial, but a book about building Ajax-enabled JSF components for sophisticated, enterprise-level Rich Internet Applications. Written by JSF experts and verified by established community figures—including Adam Winer (member of the JSF Expert Group, Java Champion), Kito D. Mann (JSFCentral.com and JSF in Action), and Matthias Weßendorf (MyFaces)—this JSF 1.2-compatible book provides reliable and groundbreaking JSF components to help you exploit the power of JSF in your Java web applications.

This book provides a blueprint for building custom JSF UI components and shows how to leverage the best browser technologies, such as AJAX, Mozilla XUL and Microsoft HTC, to deliver Rich Internet Applications.

This book covers standard best practices for behavioral and renderer-specific component classes, renderers, events and event listeners, and JSP tag handlers for each. It also covers advanced techniques such as dynamic content type negotiation, JAR-based resource delivery, and dynamic render kit selection.

Please do some experimentation of your own by modifying the code.  The sample applications in this book are not NetBeans ready yet but with ant script, you should be able to build and run.

Due to the copyright reason, the sample code zip file is not included as part of this lab, which means you will have to download the sample code zip file yourself.  If you want to have more detailed explanation on these example codes, you might want to considering purchasing the book.



(5.1) Download and unzip the sample code zip file


1. Download the sample code zip file (Pro_JSF_and_Ajax_Building_Rich_Internet_Components-2642.zip, 115M bytes) and unzip it in a directory of your choice - it will be called <UNZIP_DIRECTORY>.  If you unzipped the file in the C:\ directory on Windows platform, the <UNZIP_DIRECTORY> is C:\.  A subdirectory called 1590596951 gets created under <UNZIP_DIRECTORY>.




                                                                                                                    return to the top


Exercise 6: Ajax Patterns and Best Practices - optional

In this exercise, you will build and run AJAX sample applications from the "Ajax Patterns and Best Practices" book written by Christian Gross and published by Apress. This book shows how to build real-life and practical Ajax applications. The following is quoted from the apress website. Please see the table of contents.

Ajax is taking us into the next generation of web applications. Ajax has broken the client-server barrier by decoupling the client from the server, but an Ajax application still needs a server to extract content from. The most effective use of Ajax and the server requires an understanding of REST, an architectural style used to define Web services.

Ajax Patterns and Best Practices explores dynamic web applications that combine Ajax and REST as a single solution. A major advantage of REST is that like Ajax, it can be used with today's existing technologies.

This is an ideal book whether or not you have already created an Ajax application. Because the book outlines various patterns and best practices, you can quickly check and verify that you're building an efficient Ajax application.

Inside the book, the patterns will answer the following questions:

Please do some experimentation of your own by modifying the code.  The sample applications in this book are not NetBeans ready yet but with ant script, you should be able to build and run.

Due to the copyright reason, the sample code zip file is not included as part of this lab, which means you will have to download the sample code zip file yourself.  If you want to have more detailed explanation on these example codes, you might want to considering purchasing the book.



(6.1) Download and unzip the sample code zip file


1. Download the sample code zip file and unzip it in a directory of your choice - it will be called <UNZIP_DIRECTORY>.  If you unzipped the file in the C:\ directory on Windows platform, the <UNZIP_DIRECTORY> is C:\.  A subdirectory called 1590596951 gets created under <UNZIP_DIRECTORY>.




                                                                                                                    return to the top





Homework Exercise (for people who are taking Sang Shin's "AJAX online course")


1. The homework is to build and run the Chapter 5: Struts and Ajax sample application project from "Pro AJAX and Java Frameworks" book mentioned in Exercise 2 above.

2. Send the following files to ajaxhomework@sun.com with Subject as AJAXHomework-ajaxexamples.