A Complete Tour of  JavaServer Faces 2.0 Jim Driscoll [email_address] Andy Schwartz [email_address]
What's new?
Almost Everything
Faces Expert Group Sun – Ed Burns, Roger Kitain (Spec leads)
Oracle
Apache
IceFaces
RichFaces
RedHat / Seam
Book Authors
Many more
All  of the Faces of Faces at Sun R Ed Burns Jim Driscoll Roger Kitain Ryan Lubke
Most  of the Faces of the EG Andy Schwartz Dan Allen Alexandr Smirnov Ken Paulsen Martin Marinschek Pete Muir Kito Mann Joe Ottinger Ted Goddard Neil Griffin Jason Lee David Geary Mike Freedman Gavin King R Jeremy Grelle Keith Donald Ed Burns Jim Driscoll Roger Kitain Ryan Lubke
Some  Faces of the Faces Community Andy Schwartz Dan Allen Jacob Hookom Alexandr Smirnov Ken Paulsen Martin Marinschek Matthias We ßendorf Pete Muir Alexander Jesse Imre O ßwald Yara Senger Lincoln Baxter III Adam Winer Craig McClanahan Kito Mann Rick Hightower Joe Ottinger Ted Goddard Neil Griffin Jason Lee Stan Silvert David Geary Mike Freedman Gavin King Hazem Saleh Çağatay Çivici Dennis Byrne Roger Keays Amy Fowler Max Katz R Jeremy Grelle Keith Donald
Community Ideas Innovation happens everywhere
Most ideas were proven in the community before adoption
Some approaches (i.e., Ajax) required a good deal of merging
Highlights on each feature
Features, features
Facelets
Facelets Almost exactly the same as existing Facelets technology
JSP still supported, but... All new features will be in Facelets
Facelets now the preferred View Declaration Language Designed for JSF from the beginning
Facelets XHTML based – document validation
Better error handling, including line numbers
Library prefixes as namespaces
EL directly in page: #{bean.propertyname} Templating made easy ui:composition, ui:define, ui:insert
ui:include, ui:repeat
Composite Components
This...
Becomes this...
Or maybe this:
Composite Components Enable True Abstraction Create a true, reusable, component from an arbitrary region of a page
Built by composing other components Full support for using attached objects in the using page, and mapping them to arbitrary targets within the composite component Action methods
Validators, etc
Composite Components Builds on top of Resources and Facelets
Heavily leverages naming conventions Resource dir
Library name is directory name
Tag name is file name Essentially special-case templating
Composite Component In file ctx-root/resources/simpleout/out.xhtml: <composite:interface> <composite:attribute name=&quot;value&quot;  required=&quot;true&quot;/> </composite:interface> <composite:implementation> <h:outputText value=&quot;#{cc.attrs.value}&quot;  style=&quot;background-color: yellow&quot;/> </composite:implementation>
Composite Component <html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:h=&quot;http://java.sun.com/jsf/html&quot; xmlns:f=&quot;http://java.sun.com/jsf/core&quot; xmlns:ez=&quot;http://java.sun.com/jsf/composite/simpleout&quot;> .... <ez:out value=&quot;Test Value&quot;/> ....
Ajax
Ajax Inspiration: ADF Faces, RichFaces, IceFaces, DynamicFaces
Two entry points: Declarative:  <f:ajax>  tag, uses  AjaxBehavior
Programmatic ajax: resource library  javax.faces , resource name  jsf.js , JavaScript namespace  jsf.ajax.  jsf.ajax.request  function
Ajax Declarative ajax: useful to ajaxify non ajax pages Add ajax behaviors “invisibly”
Supports many Ajax usecases JavaScript Ajax API usage pattern jsf.ajax.request()  JavaScript function
Integrate with existing Ajax widgets Simplify lifecycle view: execute and render
Ajax Tag Example <h:outputText  id=&quot;out1&quot;  value=&quot;#{count.count}&quot;/> <h:commandButton value=&quot;Count&quot;> <f:ajax render=”out1”/> </h:commandButton>
Partial State Saving
Partial State Saving Inspired by Trinidad state saving
Save only the state that's changed since creation of the component tree
Per-view state size up to 4X smaller than before
Default for pages written with Facelets
Of interest to Java custom component authors
All standard components implement this feature - your composite components will automatically take advantage of it.
Partial State Saving PartialStateHolder  behavioral interface, extends existing  StateHolder . PartialStateHolder.markInitialState() StateHelper , from  UIComponent , does most of the work: replace ivars with keys within  StateHelper No longer need custom saveState/restoreState() implementations
Simplify Custom Components public class MyInput extends  UIComponentBase { private enum Keys { name } public String getName() { return getStateHelper().get(name); } public void setName(String nameParam) { getStateHelper().put(name, nameParam); } }
View Parameters
View Parameters Inspired by Page Parameters from JBoss Seam
Provides a way to map request parameters to special components within the view
<f:metadata>
<f:viewParam>

A Complete Tour of JSF 2

Editor's Notes

  • #2 Heading should be V3 Express? Change the dates and names
  • #41 test
  • #64 Heading should be V3 Express? Change the dates and names