• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
A Complete Tour of JSF 2
 

A Complete Tour of JSF 2

on

  • 44,766 views

A complete tour of the JSF 2 platform, as presented at Oracle Open World, 2009

A complete tour of the JSF 2 platform, as presented at Oracle Open World, 2009

Statistics

Views

Total Views
44,766
Views on SlideShare
44,259
Embed Views
507

Actions

Likes
21
Downloads
1,523
Comments
2

27 Embeds 507

http://www.slideshare.net 381
http://javawebaction.blogspot.com 63
http://javawebaction.blogspot.in 14
http://www.e-presentations.us 10
http://javawebaction.blogspot.com.tr 4
http://javawebaction.blogspot.com.br 4
http://javawebaction.blogspot.nl 3
http://javawebaction.blogspot.de 3
http://javawebaction.blogspot.co.uk 3
http://javawebaction.blogspot.hk 2
http://javawebaction.blogspot.mx 2
http://javawebaction.blogspot.ae 2
https://www.linkedin.com 2
http://javawebaction.blogspot.cz 1
http://javawebaction.blogspot.fr 1
http://webcache.googleusercontent.com 1
http://javawebaction.blogspot.ca 1
http://plus.url.google.com 1
http://b.hatena.ne.jp 1
http://adobe.com 1
http://javawebaction.blogspot.ch 1
http://javawebaction.blogspot.fi 1
http://polo.ceit.metu.edu.tr 1
http://www.docseek.net 1
http://www.linkedin.com 1
http://javawebaction.blogspot.it 1
http://javawebaction.blogspot.ro 1
More...

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

12 of 2 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Heading should be V3 Express? Change the dates and names
  • test
  • Heading should be V3 Express? Change the dates and names

A Complete Tour of JSF 2 A Complete Tour of JSF 2 Presentation Transcript

  • 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>
  • View Parameters <f:metadata> <f:viewParam name=&quot;foo&quot; value=&quot;#{bean.foo}&quot;/> </f:metadata> page1.xhtml?foo=bar bean.foo will equal “bar”
  • View Parameters
    • UIViewParameter extends UIInput
    • All attached objects valid for UIInput are valid – validation and conversion
    • Breaks the tyranny of POST
    • Lays the foundation for Bookmarkable pages
  • System Events
  • System Events
    • Influenced by JSFTemplating
      • Inspired by Solaris Dtrace, Linux strace, etc.
    • Publish/Subscribe event bus for things that happen during the JSF Lifecycle
    • Adds to event listening abilities:
      • FacesEvent/FacesListener
      • PhaseEvent/PhaseListener
      • SystemEvent/SystemEventListener
  • System Event Types
  • System Events
    • Listeners can be registered at three scopes
      • component UIComponent.subscribeToEvent()
      • view UIViewRoot.subscribeToEvent()
      • application Application.subscribeToEvent()
    • Publish is always Application.publishEvent()
  • Declarative System Events <h:inputText> <f:event type=&quot;preValidate&quot; listener=&quot;#{bean.doSomePreValidation}&quot;/> </h:inputText>
  • Resources
  • Resources
    • Avoid need for separate Filter or Servlet.
    • Resources are logically related to components, treat them that way.
    • Load from Classpath, or filesystem
    • Full support for “Library” concept, I18N, Versioning
  • Resources Java API
    • @ResourceDependency or @ResourceDependencies annotation on
        • UIComponent , Renderer , Validator , Converter , ClientBehavior
    • attributes for resource name, library name
    • attribute for target: head, body, form
    • Built in support for CSS, Image, JavaScript resources
  • Resources Markup API
    • <h:head> , <h:body>
      • Used for resource relocation targets
    • <h:outputScript> , <h:outputStylesheet>
      • Attributes for resource name, library name
      • Attribute for target: head, body, form
      • Smart includes, useful for composite components
  • Resource EL
    • #{resource['<resource>']}
    • #{resource['<library>:<resource>']}
    • Examples of use
      • <a href=&quot;#{resource['header.jpg']}&quot; />
      • <h:graphicImage value=&quot;#{resource['corp:header.jpg']}&quot; />
  • Behaviors
  • Behaviors
    • A Behavior is an interface and invents a new type of “attached object” which takes part in decode/encode.
    • ClientBehavior extends Behavior
    • Define things that happen in the view, in the browser
    • Currently only one standard ClientBehavior implementation: AjaxBehavior
    • New interface: ClientBehaviorHolder , implemented by all components in javax.faces.component.html
    • Special ClientBehaviorRenderer , does not extend Renderer .
      • getScript() , decode()
  • View Traversal
  • View Traversal
    • 1.2: UIComponent.invokeOnComponent()
      • Single component in context
    • VisitContext.createVisitContext()
    • UIComponent.visitTree(VisitContext)
      • Multiple components in context
    • Used on Ajax requests for partial traversal
    • Used by new StateManagementStrategy
  • More features
    • Annotations
    • Navigation
    • Exceptions
    • Validation
    • EL
    • Scopes
    • Project Stage
  • Annotations
    • @ManagedBean
    • @*Scoped (Session, Request, etc)
    • @ManagedProperty
    • @FacesComponent
    • @FacesConverter
    • etc.
    • With implicit Navigation, may eliminate need for faces-config.xml in many cases
  • Navigation
    • Bookmarkable Pages
      • Uses View Parameters to ensure request params are validated before rendering page
      • New components <h:link> , <h:button> , cause the browser to submit GET request, contrast with <h:command{Button|Link}>
      • <f:param> add GET params
      • <h:button outcome=”next” value=”Go” includeViewParams=”true”/>
        • Inverse mapping of view params
  • Navigation
    • Implicit Navigation
      • If you don’t want all that <navigation-rules> stuff, you can put the navigation logic straight in the page.
    • Conditional Navigation – if statements
    • ConfigurableNavigationHandler
      • Query navigation rules at run-time
  • Exceptions
    • ExceptionHandler
      • can be decorated
      • all interesting exceptions flow through the exception handler!
      • new exception type: UpdateModelException
    • ValidatorException contains multiple FacesMessages
  • EL
    • #{component} , #{cc} (composite component) : get the “currently” processed component / composite component
    • #{component.clientId}
    • #{component.messageList}
  • EL
    • Make ActionEvent param optional for action-listeners
    • For EE6, EL method invocation supports parameters
      • makes f:setPropertyActionListener obsolete
  • Validation
    • Integration with JSR 303: Bean Validation
      • @NotEmpty private String name;
      • default validator: javax.faces.Bean – automatically applied to all input fields
    • Default-validator: hook up a validator for all instances of EditableValueHolder
    • preValidate/postValidate system events
  • New Validation Tags
    • <f:validateBean>
      • Beans validation tag
    • <f:validateRequired>
      • Required field
    • <f:validateRegexp>
      • Regular expression validation
  • New Scopes
    • “ conversation” comes from Java Contexts and Dependency Injection (JSR 299) nee “Weld”
    • Flash: inspired by Ruby on Rails
      • accessible from EL or ExternalContext
      • useful for storing data for use on the “next” request
      • preserves FacesContext-messages across redirects
  • New Scopes
    • View: persists as long as user interacts with the same view
      • managed-beans can be put in view-scope
    • Custom Scopes
  • Project Stage
    • Inspired by Rails
    • Development
      • Better error reporting, debugging
    • Production
      • Better performance
  • Using JSF 2.0 Now
    • Project Mojarra
      • FCS in a few weeks
      • https://javaserverfaces.dev.java.net/
  • Color coded JavaDocs http://javaserverfaces.dev.java.net/docs/2.0/
    • New in 2.0
    • Changed in 2.0
    • Deprecated in 2.0 (JSP)
    M
  • Blogs for more detail
    • http://andyschwartz.wordpress.com/2009/07/31/whats-new-in-jsf-2/
    • http://www.java.net/blogs/driscoll/
    • http://blogs.sun.com/rlubke/
    • http://www.java.net/blogs/edburns/
    • http://www.java.net/blogs/rogerk/
  • Further Reading
    • http://javaserverfaces.dev.java.net/docs/2.0
    • David Geary's writeup:
      • http://www.ibm.com/developerworks/java/library/j-jsf2fu1/index.html
    • Java EE Tutorial (out soon)
    • Several additional books will be out this year
  • A Complete Tour of JavaServer Faces 2.0 Jim Driscoll [email_address] Andy Schwartz [email_address]