David wrote both Graphic Java Swing and Core JavaServer Faces (with Cay Horstmann). Both of these were best sellers on Java component frameworks. Not only that, but he's fun to talk to and lives just south of me in Colorado.
Agenda: Ajaxian Faces Essentials, Roadmap, Form Completion, Realtime Validation, Ajaxian Components, Ajax with Shale and Prototype.
Enterprise Java and Ajax: you invoke a URL from the client (XHR), then handle the URL on the server. This handling is usually done by a servlet, filter or a JSF phase listener. These return HTML or XML to the client. Then the client merges the response into the DOM on the client.
JSF and Ajax: JSF is an excellent framework for Ajax. Why? Because of its component model: GET and POST requests are supported and it has custom components and renderers. Furthermore, JSF has lifecycle and event handlers - phase listeners and allows complete control over the lifecycle.
Arm yourself with tools: Firefox with the Web Developer Toolbar. Most helpful features: outlining block elements and DOM inspector. Debuggers on client and server: IDEA on the server, Venkman on the server.
Good Resources: Java EE Blueprints, Ajax Magazine and MSDN.
<h:form id="form"> <h:inputText id="name"/> ... </h:form>
In the above example, the component id is "name" and the client id is "form:name". To do minimal Ajax with JSF, you can use a non-Faces object to handle the Ajax requests with a servlet or filter. All you really need to know is how to reference client ids vs. the ids you code into your view templates.
Realtime validation: to do this, you need access to the view state. Ajax will fire a component's validators, invoke a phase listener (after the Restore View phase), POST a request with XHR and utilize client-side state handling. A typical component tree for a form consists of a UIViewRoot, an HtmlOuputText (instructions for form) an HtmlForm and an HtmlPanelGrid that contains all of the input components.
The JSF Lifecycle: Restore View -> Apply Request Values -> Process Validations -> Update Model -> Invoke Application -> Render Response. You have to do a post with JSF, otherwise the view state won't be available.
- Web flow
- Remote method calls
- Tiger extensions
- Integration with: Spring, Tiles, JNDI
- View controllers
- Testing framework
- HTML views (a.l.a. Tapestry and Facelets)
David gave a quick preview of Shale and showed how much easier it makes Ajax. Basically, you give a specialized URL on your client - and using a syntax of "dynamic/managedBeanName/method", it calls that method on the server. Pretty cool stuff, but doesn't seem a whole lot different from what DWR offers for JSF. "Shale is a proving ground for JSF 2.0, hopefully all its add-ons will make it into the next version of the spec." When David says stuff like this, I'm tempted to use Shale in AppFuse for its JSF support - especially since Shale can work with any JSF implementation (1.1 RI, MyFaces or 1.2 RI).
As usual, this was a good talk by David. He's always entertaining and fun to harass.