Ajax and Java
Ajax and Java
Ajax and Java
• Ryan Asleson
• Nathaniel T. Schutta
www.ntschutta.com/jat/
• Give me tools!
http://www.v-bal.nl/logos/ajax.jpg
http://movies.yahoo.com/shop?d=hv&id=1808444810&cf=pg&photoid=521827&intl=us http://www.cleansweepsupply.com/pages/skugroup1068.html
Give me an ‘A’
• Ajax is a catch-phrase - several technologies
• We gain flexibility
http://www.adaptivepath.com/publications/essays/archives/000385.php
What’s old is new again
• XHR was created by Microsoft in IE5
Google Maps
Typical Interaction
Ajax Enabled Web Application Web Container
3
XHR Server Resource
6 5
2
function callback() {
//do something
}
4
1
Event Data store
Client Server
Frameworks
• Don’t do the heavy lifting yourself!
• getElementsByClassName
• Insertion
• Before/Top/Bottom/After
new Ajax.Request(url, {
asynchronous: true,
method: "get",
parameters: "foo=bar",
onComplete: function(request) {
showResults(request.responseText);
}
});
Ajax.Updater
• Similar to Ajax.Request
• http://www.sergiopereira.com/articles/
prototype.js.html
• http://encytemedia.com/blog/
• http://particletree.com/
script.aculo.us
• Built on top of Prototype
• Handful of JS files
Effect.Highlight
• Asynchronous calls aren’t obvious to users
new Effect.Highlight('fadeMe',
{ startcolor: '660000',
endcolor: 'FFFF00',
restorecolor: '#ffffff'});
Combination Effects
• Effect.Parallel allows you to do a lot
• Appear
• Puff
• Shake
• Fold
• Grow
• Simple to use:
new Ajax.Autocompleter(textField, div, url, options)
• Tell it:
• Very ambitious!
• Reusable components
• Simple RPC
• Set of utilities
• Logging
• Events
• Set of controls
• AutoComplete
• Calendar
• Menu
Struts
• Ajax interactions benefit from all of Struts' features
including:
• Lots of promise!
Spare me the pain
• Even with frameworks, still some JavaScript
• Firefox Extensions
http://www.mozilla.org/projects/inspector/
JsUnit
http://www.edwardh.com/jsunit/
Selenium
http://www.openqa.org/selenium/
FireBug
https://addons.mozilla.org/firefox/1843/previews/
http://www.joehewitt.com/software/firebug/
https://addons.mozilla.org/firefox/1843/
What’s next?
• Better tool support starting to arrive
• Code bloat
• Auto complete
• Recalculate
• www.ajaxmatters.com/r/welcome
• www.ajaxblog.com/
• http://labs.google.com/
• www.adaptivepath.com/
• http://www.ntschutta.com/jat/
• Lots of books...
To sum up
• Ajax changes the request/response paradigm
• Start slow
• Embrace change!
Discount code!
Interested in an e-book version of our second book
Pro Ajax and Java Frameworks?
Use this code:
THCHOPGBXVSZ
at
http://apress.com/