230 likes | 427 Views
Creating AJAX-Powered Forms with the Dojo Toolkit. Presented By: James Harmon Object Training Group, Inc. www.ObjectTrainingGroup.com JamesHarmon@gmail.com. Goal. Increase the usability of your existing web forms by using features of the dojo toolkit
E N D
Creating AJAX-Powered Forms with the Dojo Toolkit Presented By: James Harmon Object Training Group, Inc. www.ObjectTrainingGroup.com JamesHarmon@gmail.com
Goal • Increase the usability of your existing web forms by using features of the dojo toolkit • Changes should be easy and quick to implement • Improve perceived performance • Increase functionality of existing widgets • Improve data validation
Review Sample Application • No client side validation • No JavaScript validation provided at all • Server side validation • Part of request / response cycle • Widgets • Limitations
Approach • Add client side validation • Use server side validation on each widget instead of entire form • Use specialized dojo widgets to improve functionality
Steps • Install dojo • Improve client side validation • Use server side validation • Use specialized widgets • Use the dojo form widget
Install dojo • Download from dojotoolkit.org • Use AOL CDN (content distribution network)
Client Side Validation • Mark widget as using dojo client side validation • Specify the transformation and validation features
First Name • Transformation features • First character upper case • Validation Requirements • Required field
Review before/after DOM • Review DOM view before using dojo • Review DOM view after using dojo • Discuss new event model for DOM element
Validation Error Messages • Configurable properties • DOM view of error message tags • CSS style properties
Transformations • Attributes on field type boxes which change the values of the field • Uppercase • Lowercase • trim • Upper case first character • Digit (remove all non digit characters)
Validations • Attributes on field type boxes which cause validations to be applied to field • Error message must be provided • Style of error messages can be over-ridden • Required • maxLength • Size
Server Side Validation • Determine fields which can be validated on server side using Ajax • Username (or email) already used • The server can do more than provide validation • Any data or message can be sent back to client
User Name • Passing data to the server • Don’t wait until the entire form is processed before letting using know if they’ve selected a good user name • Handling the response from the server • Not only invalid data message, but possible suggestions as well
City, State, ZipCode • State data comes from the server • Could be preloaded • Watch the state selection as user types • IL is Illinois not Idaho • City and Zip data comes from server based on selected state • Too much data to preload into the page
Specialized dojo Widgets • Date Picker • Rich Text Editor • Others
Date Picker • Add the widget to the page • Populate the widget with data • Get data from the widget
Rich Text Editor • Add the widget to the page • Populate the widget with data • Get data from the widget
Dojo Form Widget • Creating a dojo Form • Add widget to the page • Populate the widget with data • Serializing Data • Passing Data to Server • Graceful Fallback
Where To Go From Here • www.dojotoolkit.org • Download slides and code from • www.ObjectTrainingGroup.com/dojo