Web 2.0 and Ajax With Java
Web 2.0 and Ajax With Java
Agenda
Definitions: Web 2.0, Rich Web Applications, AJAX Demo Guidelines JSF Approach AJAX BluePrints Futures Q&A
Agenda
Definitions: Web 2.0, Rich Web Applications, AJAX AJAX UseCases? Demo Guidelines JSF Approach AJAX BluePrints Futures Q&A
3
Web 2.0
Web as a Platform Collection Intelligence
> Folksonomy Collaborative Categorization
AJAX
Asynchronous JavaScript + XML
AJAX is using JavaScript, namely the XmlHttpRequest object, to communicate asynchronously with a server-side component and dynamically update the source of an HTML page based on the resulting XML/Text response.
10
11
Servlet
public void doGet(HttpServletRequest request, HttpServletResponse throws IOException, ServletException { response)
response.setStatus(HttpServletResponse.SC_NO_CONTENT);
12
13
Demo
AJAX Demo
14
Agenda
Definitions: Web 2.0, Rich Web Applications, AJAX Demo Guidelines JSF Approach AJAX BluePrints Futures Q&A
15
AJAX Guidelines
JavaScript Libraries Usability I18n AJAX Design Architectures HTTP methods Return content-types Usecases/Patterns Security
16
JavaScript Libraries
Prototype RICO Script.aculo.us Dojo Zimbra
Usability
Back/Forward/Refresh Buttons Bookmarking URL sharing Printing 508 Compliance
Recommendation: Consider the meaning of each and weigh the benefits when designing your application. 18
XMLHttpRequest (XHR)
HTTP Method
> GET - When the result of N > 0 requests is the same. > POST - When operation has side-effects and changes
Concurrent Requests
> Max is 2 (IE) Consider - Pooling > JavaScript Closures Inline functions
Recommendation: Take care using the XHR. Use Closures to track the requests/callbacks. Consider using a library. 19
Internationalization (I18n)
Page Content Type
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
AJAX Design
Add Around the Edges
> Small components (autocomplete, tree, partial submit)
Recommendation: Consider designing initial AJAX applications around the edges as you gain experience. Don't go overboard. 21
Architectures
Server Centric
> Server Renders Everything
Client Centric
> More JavaScript > Page as the Application > Client Controller
Recommendation: If you already have a server centric architecture consider adding some client centric components. When using a client centric architecture consider using an existing library. 22
JavaScript
> Evaluated in JavaScript using eval() > JavaScript object representations of data(JSON)
Recommendation: Use XML for structured portable data. Use plain text for when injecting content into the HTML. Use JavaScript to return object representations data. 23
Uscases/Patterns
Advanced Controls Autocomplete Observer Master Details Partial Submit Server Side Validation Value List Handler
Security
Sandboxed
> Cross Domain XMLHttpRequest restricted > Access to file system restricted
HTTPS Requires a page refresh JavaScript Libraries for Encryption Exist JavaScript code visible to the world
Recommendation: Use HTTPS when you want to secure AJAX communication. Don't put compromising code in your JavaScript 25
Performance
http://www.macrumors.com/events/mwsf2006-stats.php We peaked at approximately 103,000 simultaneous web visitors and 6,000 IRC viewers during the Keynote speech and transmited over 32 GB of data in a three hour period. If not for the efficiency of the MacRumorsLive AJAX update system, the same webcast would have required approximately twice as many servers and would have had to transfer almost 6 times as much data (196 GB).
Agenda
Definitions: Web 2.0, Rich Web Applications, AJAX Demo Guidelines JSF Approach AJAX BluePrints Futures Q&A
27
29
30
31
AJAX BluePrints
BluePrints Solutions Catalog Entries on AJAX
> NetBeans > Command Line > Written for Glassfish http://glassfish.dev.java.net
32
Futures
AJAX Pet Store More Java BluePrints Solutions Catalog entries More Java BluePrints AJAX components Better tool support Web 2.0/AJAX focus for JavaOne 2006
33
Summary
Java provides the ideal platform for AJAX and Web 2.0 style applications Use AJAX where it makes sense. Follow the guidelines The BluePrints team and BluePrints Solutions Catalog is a great AJAX resources
34
Resources
BluePrints AJAX Page:
http://java.sun.com/blueprints/ajax.html
Quirksmode.org
http://www.quirksmode.org
35
Q&A