A Complete Tour of JSF 2

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

1 comments

Comments 1 - 1 of 1 previous next Post a comment

Post a comment
Embed Video
Edit your comment Cancel

Notes on slide 1

Heading should be V3 Express? Change the dates and names

test

Heading should be V3 Express? Change the dates and names

6 Favorites

A Complete Tour of JSF 2 - Presentation Transcript

  1. A Complete Tour of JavaServer Faces 2.0 Jim Driscoll [email_address] Andy Schwartz [email_address]
  2. What's new?
  3. Almost Everything
  4. Faces Expert Group
    • Sun – Ed Burns, Roger Kitain (Spec leads)
    • Oracle
    • Apache
    • IceFaces
    • RichFaces
    • RedHat / Seam
    • Book Authors
    • Many more
  5. All of the Faces of Faces at Sun R Ed Burns Jim Driscoll Roger Kitain Ryan Lubke
  6. 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
  7. 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
  8. 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
  9. Features, features
  10. Facelets
  11. 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
  12. 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
  13. Composite Components
  14. This...
  15. Becomes this...
  16. Or maybe this:
  17. 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
  18. 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
  19. 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>
  20. 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;/> ....
  21. Ajax
  22. 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
  23. 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
  24. 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>
  25. Partial State Saving
  26. 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.
  27. 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
  28. 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); } }
  29. View Parameters
  30. 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>
  31. 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”
  32. 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
  33. System Events
  34. 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
  35. System Event Types
  36. System Events
    • Listeners can be registered at three scopes
      • component UIComponent.subscribeToEvent()
      • view UIViewRoot.subscribeToEvent()
      • application Application.subscribeToEvent()
    • Publish is always Application.publishEvent()
  37. Declarative System Events <h:inputText> <f:event type=&quot;preValidate&quot; listener=&quot;#{bean.doSomePreValidation}&quot;/> </h:inputText>
  38. Resources
  39. 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
  40. 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
  41. 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
  42. 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; />
  43. Behaviors
  44. 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()
  45. View Traversal
  46. 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
  47. More features
    • Annotations
    • Navigation
    • Exceptions
    • Validation
    • EL
    • Scopes
    • Project Stage
  48. Annotations
    • @ManagedBean
    • @*Scoped (Session, Request, etc)
    • @ManagedProperty
    • @FacesComponent
    • @FacesConverter
    • etc.
    • With implicit Navigation, may eliminate need for faces-config.xml in many cases
  49. 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
  50. 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
  51. Exceptions
    • ExceptionHandler
      • can be decorated
      • all interesting exceptions flow through the exception handler!
      • new exception type: UpdateModelException
    • ValidatorException contains multiple FacesMessages
  52. EL
    • #{component} , #{cc} (composite component) : get the “currently” processed component / composite component
    • #{component.clientId}
    • #{component.messageList}
  53. EL
    • Make ActionEvent param optional for action-listeners
    • For EE6, EL method invocation supports parameters
      • makes f:setPropertyActionListener obsolete
  54. 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
  55. New Validation Tags
    • <f:validateBean>
      • Beans validation tag
    • <f:validateRequired>
      • Required field
    • <f:validateRegexp>
      • Regular expression validation
  56. 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
  57. New Scopes
    • View: persists as long as user interacts with the same view
      • managed-beans can be put in view-scope
    • Custom Scopes
  58. Project Stage
    • Inspired by Rails
    • Development
      • Better error reporting, debugging
    • Production
      • Better performance
  59. Using JSF 2.0 Now
    • Project Mojarra
      • FCS in a few weeks
      • https://javaserverfaces.dev.java.net/
  60. 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
  61. 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/
  62. 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
  63. A Complete Tour of JavaServer Faces 2.0 Jim Driscoll [email_address] Andy Schwartz [email_address]

+ Jim DriscollJim Driscoll, 1 month ago

custom

2315 views, 6 favs, 0 embeds more stats

A complete tour of the JSF 2 platform, as presented more

More info about this document

© All Rights Reserved

Go to text version

  • Total Views 2315
    • 2315 on SlideShare
    • 0 from embeds
  • Comments 1
  • Favorites 6
  • Downloads 95
Most viewed embeds

more

All embeds

less

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

Cancel
File a copyright complaint
Having problems? Go to our helpdesk?

Categories