Magazine
 
Quick Review:Ajax
 

Automate data entry with Web services and Ajax

Solution overview

The list below shows the steps involved in completing this solution. (Don’t worry; the remainder of this article walks you through these steps one by one.) Note that a partial is a Ruby on Rails term. It’s a reusable piece of code related to what gets displayed in the Web browser. Most modern frameworks include some kind of template and partial functionality that dynamically assembles pieces of the template to produce a Web page. Partials are a real convenience to application developers and rastically help reduce the burden of development. The RoR naming convention is to prefix a partial with an underscore (for example, _addressForm.rhtml).

  • Modify the _form.rhtml partial to display the ZIP code before the city and state.
  • Add a partial (_cityState.rhtml) to display the input fields for city and state.
  • 3. Modify the _form.rhtml partial to “listen” for changes to the ZIP code field and make an
    Ajax call to the server.
  • Modify the controller to validate the ZIP code (5 numeric digits). If not valid, return a blank Ajax response to the client.
  • Modify the controller to create a valid XML request to send to the USPS Web service.
  • Modify the controller to receive and parse a XML response from the USPS Web service.
  • Modify the Ajax response to populate the _cityState partial with the Web services’ values.
  • Figure out some ways to improve the solution, and e-mail the author with your suggestions.

June 2008 | Java Jazz Up | 15
 
previous
index
next
 
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,

30
, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,   Download PDF