1 / 46

JSF 2.2 New Features In Context

JSF 2.2 New Features In Context. Ed Burns Roger Kitain Oracle America, Inc. Program Agenda. Stateless JSF Resource Library Contracts Faces Flows HTML5 Friendly Markup.

purity
Download Presentation

JSF 2.2 New Features In Context

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JSF 2.2 New Features In Context Ed BurnsRoger Kitain Oracle America, Inc.

  2. Program Agenda • Stateless JSF • Resource Library Contracts • Faces Flows • HTML5 Friendly Markup

  3. The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract.It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.

  4. Stateless JSF What is state? • Kinds of state in a JSF app • UIComponent state • Model tier state • Persistence tier state

  5. Stateless JSF What is state? • Kinds of state in a JSF app • UIComponent state • Model tier state • Persistence tier state

  6. Stateless JSF What is state? • Kinds of state in a JSF app • UIComponent state • Model tier state • Persistence tier state • Context: Stateless is important mostly as performance concern • See http://bit.ly/LeonardoJsfPerformance Leonardo Uribe’s paper • Much can be done in the way you use JSF to reduce statefulness

  7. Stateless JSF JSF 2.2 approach to stateless • Leverage existing API • Biggest gain for smallest change • Expose existing UIComponent transient property on f:view<f:view transient=“true”> • Spec changes in Restore View Phase, ResponseStateManager • Be advised • Must be on outer-most <f:view> in Facelets inclusion • View scoped managed beans will not work if the view is marked stateless

  8. Stateless JSF Why is this important? • Automatic state management is a key value-add of JSF • Differentiates it from RESTful • Pros • Can be lazy with your UI,

  9. Resource Library Contracts What Is A Resource Library Contract? • Extension of JSF 2.0 Resource Library concept • A “contracts” directory containing: • templates • insertion points in those templates • resources (images, css, JavaScript…) • Any template client that honors this informal contract can be used with any resource library contract that implements that contract

  10. Resource Library Contracts What Is A Resource Library Contract? • Think facelets templates • Builds on JSF 2.0 packaging scheme: • Special directory in web app root (useful for development): • /contracts • Special location in Classpath(useful for deployment): • /META-INF/contracts

  11. Resource Library Contracts Facelets Review

  12. Resource Library Contracts Facelets Review

  13. Resource Library Contracts A Contract is Born

  14. Resource Library Contracts Loading Conventions

  15. Resource Library Contracts Loading Conventions

  16. Resource Library Contracts Loading Conventions

  17. Resource Library Contracts Loading Conventions

  18. Resource Library Contracts Loading Configuration

  19. Resource Library Contracts Loading Configuration

  20. Resource Library Contracts How Do I Use Resource Library Contract? • Convention • Contracts in the application apply to all pages • Contracts discovered at startup; • Assumes no naming collisions • Configuration • Contracts in faces-config.xml: <resource-library-contracts> element • Contracts on <f:view> • contracts attributein<f:view> declares the view is only able touse these named contracts

  21. Demo

  22. Faces Flows What Is A Faces Flow? • An application sub-module • Well defined entry and exit • Input and output parameters • Pre and post handlers • Builds on navigation concepts • Inspired, standardized from: • ADF Task Flows • Spring Web Flow • Apache MyFaces CODI

  23. Faces Flows What Is A Faces Flow? • Builds on JSF 2.0 packaging scheme: • Special directory in web app root (useful for development): • /flows • Special location in Classpath (useful for deployment): • /META-INF/flows

  24. Faces Flows What Is A Faces Flow? • Similar to a Java method: • Can be “called” from any place in application • Single entry point • Input parameters and return values • Well defined interface contract • Internal implementation details hidden • New facesFlowScope for flow local storage • New @FlowScopedCDI annotation: automatic activation/passivation

  25. Faces Flows Flow Navigation • Navigation between flow “nodes” • Node types: • View • Method Call • Switch • Flow Call • Flow Return

  26. Faces Flows • Runtime instance: • javax.faces.flow.Flow • JSF 2.2 authoring experience: • XML • Builder (Java Programmatic) • Navigation

  27. Faces Flows View Nodes • Represent pages within the flow • The id attribute is used in navigation rules • Identify the VDL document used to render the view

  28. Faces Flows Method Call Nodes • Invoke logic from flow graph • Decouple invocation of logic from the UI component • Method identified by EL expression • Outcome from either method result or default value

  29. Faces Flows Switch Nodes • Hint: Like a Java switch statement • Make navigation decisions in the flow graph • Generate different outcomes based on boolean EL expression • Default outcome if no expression evaluates to true

  30. Faces Flows Flow Call Nodes • Hint: Like calling a method in Java code • Make calls to other flows • Pass parameter values to called flows • Store values returned from flows

  31. Faces Flows Flow Return Nodes • Hint: Like a Java return statement • Return to calling flow • Identify return values to be passed back to caller

  32. Faces Flows Flow Definition • Name of the flow • Where does the flow start? • Input values • Optional initializer & finalizer

  33. Faces Flows Flow Definition

  34. HTML5 Friendly Markup But First…. A Review • The View Declaration Language (VDL) is used to produce JSF Views Standard Facelets VDL consists of: • HTML Markup • JSF Components (tags in markup) • HTML markup pass through straight to the browser • JSF Components perform server-side actions, during the lifecycle

  35. HTML5 Friendly Markup HTML5 Doctype • HTML5 doctype is always rendered (default) • If you need JSF 2.1 behavior (passing doctype through from source): <faces-config-extension> <facelets-processing> <file-extension>.xhtml</file-extension> <process-as>xhtml</process-as> <facelets-processing> </faces-config-extension>

  36. HTML5 Friendly Markup Pass-through Attributes • Attributes passed to rendered output element directly (components do not process them) • Possible to render HTML5 attributes (or any attribute) not supported by component • Convenient – as HTML5 is still a “work in progress” and could be for sometime

  37. HTML5 Friendly Markup Pass-through Attributes • Example: Namespace Approach • Namespace: xmlns:p=http://xmlns.jcp.org/jsf/passthrough • Markup: <h:inputText id=“input” value=“” p:placeholder=“Enter Text” /> • Rendered output: <input type=“text” id=“input” value=“” placeholder=“Enter Text” />

  38. HTML5 Friendly Markup Pass-through Attributes • Example: Nested Approach • Markup: <h:inputText id=“input” value=“” > <f:passThroughAttribute name=“passthrough” value=“Enter Text”/> </h:inputText> • Rendered output: <input type=“text” id=“input” value=“” placeholder=“Enter Text” /> • You can nest multiple <f:passThroughAttribute> • You can use <f:passThroughAttributes> • You can use EL expressions

  39. HTML5 Friendly Markup Pass-through Elements • “A page without JSF tags” • Links HTML elements to server-side component instances • At least one of the element’s attributes must be in the namespace: http://xmlns.jcp.org/jsf • Type of component created is determined by element name and identifying attribute (if element name alone not sufficient)

  40. HTML5 Friendly Markup Pass-through Elements • Example: • Namespace: xmlns:jsf=“http://xmlns.jcp.org/jsf” • Markup: <head jsf:id=“head=“>…</head> <body jsf:id=“body”> <form jsf:id=“form”> <input type=“text” id=“input” jsf:value=“” placeholder=“Enter Text”/> </form> </body> • All markup elements will be represented as server side JSF components: • <h:head>, <h:body>, <h:form>, <h:inputText>

  41. HTML5 Friendly Markup Pass-through Elements • More mapping examples: • Complete mappings of elements and component tags: • http://docs.oracle.com/javaee/7/api/javax/faces/view/faceletsTagDecorator.html

  42. HTML5 Friendly Markup Pass-through Elements • You can also mix and match markup: <input type=“text” jsf:value=“”> <f:validateLength minimum=“5”/> </input> • What happens if there is no existing mapping? • JSF creates a special component: component-family: javax.faces.Panel renderer-type: javax.faces.passthrough.Element http://docs.oracle.com/javaee/7/javaserverfaces/2.2/vdldocs/facelets/jsf/element.html

  43. Demo

  44. Resources • JSF Specification: http://jcp.org/en/jsr/detail?id=344 • JSF Implementation: http://javaserverfaces.java.net/

More Related