JSF CR 08
JSF CR 08
Version 2.0
Ed Burns, Roger Kitain, editors
Ea 0 8
rly 09
20
D
ra
10
ft
Re
vi
ew
See <https://javaserverfaces-spec-public.dev.java.net/>
2
September 2008
Version: 2.0
NOTICE
The Specification is protected by copyright and the information described therein may be protected by one or more U.S. patents, foreign patents, or pending
applications. Except as provided under the following license, no part of the Specification may be reproduced in any form by any means without the prior
written authorization of Sun Microsystems, Inc. ("Sun") and its licensors, if any. Any use of the Specification and the information described therein will be
governed by the terms and conditions of this Agreement.
Subject to the terms and conditions of this license, including your compliance with Paragraphs 1 and 2 below, Sun hereby grants you a fully-paid, non-
exclusive, non-transferable, limited license (without the right to sublicense) under Sun's intellectual property rights to:
1.Review the Specification for the purposes of evaluation. This includes: (i) developing implementations of the Specification for your internal, non-
commercial use; (ii) discussing the Specification with any third party; and (iii) excerpting brief portions of the Specification in oral or written communications
which discuss the Specification provided that such excerpts do not in the aggregate constitute a significant portion of the Technology.
2.Distribute implementations of the Specification to third parties for their testing and evaluation use, provided that any such implementation:
(i) does not modify, subset, superset or otherwise extend the Licensor Name Space, or include any public or protected packages, classes, Java interfaces, fields
or methods within the Licensor Name Space other than those required/authorized by the Specification or Specifications being implemented;
(ii) is clearly and prominently marked with the word "UNTESTED" or "EARLY ACCESS" or "INCOMPATIBLE" or "UNSTABLE" or "BETA" in any list
of available builds and in proximity to every link initiating its download, where the list or link is under Licensee's control; and
(iii) includes the following notice:
"This is an implementation of an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation
purposes only. The code is not compatible with any specification of the JCP."
The grant set forth above concerning your distribution of implementations of the specification is contingent upon your agreement to terminate development
and distribution of your "early draft" implementation as soon as feasible following final completion of the specification. If you fail to do so, the foregoing grant
shall be considered null and void.
No provision of this Agreement shall be understood to restrict your ability to make and distribute to third parties applications written to the Specification.
Other than this limited license, you acquire no right, title or interest in or to the Specification or any other Sun intellectual property, and the Specification may
only be used in accordance with the license terms set forth herein. This license will expire on the earlier of: (a) two (2) years from the date of Release listed
above; (b) the date on which the final version of the Specification is publicly released; or (c) the date on which the Java Specification Request (JSR) to which
the Specification corresponds is withdrawn. In addition, this license will terminate immediately without notice from Sun if you fail to comply with any
provision of this license. Upon termination, you must cease use of or destroy the Specification.
"Licensor Name Space" means the public class or interface declarations whose names begin with "java", "javax", "com.sun" or their equivalents in any
subsequent naming convention adopted by Sun through the Java Community Process, or any recognized successors or replacements thereof
TRADEMARKS
No right, title, or interest in or to any trademarks, service marks, or trade names of Sun or Sun's licensors is granted hereunder. Sun, Sun Microsystems, the Sun
logo, Java, JavaServer, JavaServer Faces are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
DISCLAIMER OF WARRANTIES
THE SPECIFICATION IS PROVIDED "AS IS" AND IS EXPERIMENTAL AND MAY CONTAIN DEFECTS OR DEFICIENCIES WHICH CANNOT OR
WILL NOT BE CORRECTED BY SUN. SUN MAKES NO REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT THAT
THE CONTENTS OF THE SPECIFICATION ARE SUITABLE FOR ANY PURPOSE OR THAT ANY PRACTICE OR IMPLEMENTATION OF SUCH
CONTENTS WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADE SECRETS OR OTHER RIGHTS. This document does not
represent any commitment to release or implement any portion of the Specification in any product.
THE SPECIFICATION COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS. CHANGES ARE PERIODICALLY
ADDED TO THE INFORMATION THEREIN; THESE CHANGES WILL BE INCORPORATED INTO NEW VERSIONS OF THE SPECIFICATION, IF
ANY. SUN MAY MAKE IMPROVEMENTS AND/OR CHANGES TO THE PRODUCT(S) AND/OR THE PROGRAM(S) DESCRIBED IN THE
SPECIFICATION AT ANY TIME. Any use of such changes in the Specification will be governed by the then-current license for the applicable version of the
Specification.
LIMITATION OF LIABILITY
TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY DAMAGES, INCLUDING
WITHOUT LIMITATION, LOST REVENUE, PROFITS OR DATA, OR FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF OR RELATED TO ANY FURNISHING,
PRACTICING, MODIFYING OR ANY USE OF THE SPECIFICATION, EVEN IF SUN AND/OR ITS LICENSORS HAVE BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
You will hold Sun (and its licensors) harmless from any claims based on your use of the Specification for any purposes other than the limited right of evaluation
as described above, and from any claims that later versions or releases of any Specification furnished to you are incompatible with the Specification provided
to you under this license.
REPORT
You may wish to report any ambiguities, inconsistencies or inaccuracies you may find in connection with your evaluation of the Specification ("Feedback").
To the extent that you provide Sun with any Feedback, you hereby: (i) agree that such Feedback is provided on a non-proprietary and non-confidential basis,
and (ii) grant Sun a perpetual, non-exclusive, worldwide, fully paid-up, irrevocable license, with the right to sublicense through multiple levels of sublicensees,
to incorporate, disclose, and use without limitation the Feedback for any purpose related to the Specification and future versions, implementations, and test
suites thereof.
GENERAL TERMS
Any action related to this Agreement will be governed by California law and controlling U.S. federal law. The U.N. Convention for the International Sale of
Goods and the choice of law rules of any jurisdiction will not apply.
The Specification is subject to U.S. export control laws and may be subject to export or import regulations in other countries. Licensee agrees to comply strictly
with all such laws and regulations and acknowledges that it has the responsibility to obtain such licenses to export, re-export or import as may be required after
delivery to Licensee.
This Agreement is the parties' entire agreement relating to its subject matter. It supersedes all prior or contemporaneous oral or written communications,
proposals, conditions, representations and warranties and prevails over any conflicting or additional terms of any quote, order, acknowledgment, or other
communication between the parties relating to its subject matter during the term of this Agreement. No modification to this Agreement will be binding, unless
in writing and signed by an authorized representative of each party.
Contents
Preface 1
Changes between 1.2 Final and Early Draft Review 2 1
Section 2.1 “Request Processing Lifecycle Scenarios” 1
Section 2.2 “Standard Request Processing Lifecycle Phases” 1
Section 2.2.1 “Restore View” 2
Section 2.2.2 “Apply Request Values” 2
Section 2.2.2.1 “Apply Request Values Partial Processing” 2
Section 2.2.3 “Process Validations” 2
Section 2.2.3.1 “Partial Validations Partial Processing” 2
Section 2.2.4 “Update Model Values” 2
Section 2.2.4.1 “Update Model Values Partial Processing” 2
Section 2.2.6 “Render Response” 3
New Section 2.6 “Resource Handling” 3
New Section 2.6.2 “Rendering Resources” 3
New Section 2.6.2.1 “Relocatable Resources” 3
New Section 2.6.2.2 “Resource Rendering Using Annotations” 3
Section 3.1.8 “Component Tree Navigation” 3
Section 3.1.10 “Generic Attributes” 4
Section 3.1.10.1 “Special Attributes” 4
Contents iv
Section 3.1.12 “Component Specialization Methods” 4
Section 3.1.13 “Lifecycle Management Methods” 4
Section 3.1.14 “Utility Methods” 4
Section 3.2.5.1 “Properties” 4
Section 3.2.6.2 “Methods” 4
Section 3.2.7 “SystemEventListenerHolder” 5
Section 3.3.2 “Converter” 5
Section 3.4.1 “Overview” 5
Section 3.4.2.6 “Event Broadcasting” 5
Section 3.4.3.1 “Event Classes” 5
Section 3.4.3.4 “Listener Registration By Annotation” 5
Section 3.5.2 “Validator Classes” 5
Section 4.1.17.2 “Properties” 6
Specify the viewMap property on UIViewRoot. 6
Section 4.1.17.3 “Methods” 6
Section 4.1.17.4 “Events” 6
Section 4.1.17.5 “Partial Processing” 6
Section 4.2.1.2 “Methods” 6
Section 3.6 “Composite User Interface Components” 6
Section 5.2.1 “MethodExpression Syntax and Semantics” 6
Section 5.4.1 “Managed Bean Lifecycle Annotations” 7
Section 5.6.1.1 “Faces Implicit Object ELResolver for Markup Pages” and
Section 5.6.2.1 “Implicit Object ELResolver for Programmatic Access”
7
Section 5.6.1.2 “ManagedBean ELResolver” 7
Section 5.6.2.1 “Implicit Object ELResolver for Programmatic Access” 7
Section 5.6.2.4 “Resource ELResolver” 7
Section 6.1.2 “Attributes” 7
Section 6.1.8 “ResponseStream and ResponseWriter” 8
Contents vi
Section 13.3.1.1 “Use Case” 12
Section 13.3.2 “Sending an Ajax Request” 12
Section 13.3.2.1 “Usage” 12
Section 13.3.2.2 “Request Sending Specifics” 12
Section 13.3.2.3 “Use Case” 12
Section 13.3.2.4 “Ajax Request Queueing” 12
Section 13.3.2.5 “Request Callback Function Specifics” 13
Section 13.3.3 “Processing The Ajax Response” 13
Section 13.4 “Partial View Traversal” 13
Section 13.4.1 “Partial View Execute” 13
Section 13.4.2 “Partial View Render” 13
Section 13.4.3 “Sending The Response to The Client” 13
Section 1.1 “XML Schema Definition” 13
Standard HTML RenderKit specification 14
component-family: javax.faces.Graphic renderer-type:
javax.faces.Image 14
component-family: javax.faces.Output renderer-type: javax.faces.Body
14
component-family: javax.faces.Output renderer-type: javax.faces.Head
14
component-family: javax.faces.Output renderer-type:
javax.faces.resource.Script 14
component-family: javax.faces.Output renderer-type:
javax.faces.resource.Stylesheet 14
General Changes 14
Other Java™ Platform Specifications 15
Related Documents and Specifications 16
Terminology 16
Providing Feedback 16
Acknowledgements 16
Contents viii
2.2.2 Apply Request Values 2–7
2.2.2.1 Apply Request Values Partial Processing 2–8
2.2.3 Process Validations 2–8
2.2.3.1 Partial Validations Partial Processing 2–9
2.2.4 Update Model Values 2–10
2.2.4.1 Update Model Values Partial Processing 2–10
2.2.5 Invoke Application 2–11
2.2.6 Render Response 2–11
2.3 Common Event Processing 2–13
2.4 Common Application Activities 2–14
2.4.1 Acquire Faces Object References 2–14
2.4.1.1 Acquire and Configure Lifecycle Reference 2–14
2.4.1.2 Acquire and Configure FacesContext Reference 2–15
2.4.2 Create And Configure A New View 2–15
2.4.2.1 Create A New View 2–15
2.4.2.2 Configure the Desired RenderKit 2–16
2.4.2.3 Configure The View’s Components 2–17
2.4.2.4 Store the new View in the FacesContext 2–17
2.5 Concepts that impact several lifecycle phases 2–17
2.5.1 Value Handling 2–17
2.5.1.1 Apply Request Values Phase 2–18
2.5.1.2 Process Validators Phase 2–18
2.5.1.3 Executing Validation 2–18
2.5.1.4 Update Model Values Phase 2–18
2.5.2 Localization and Internationalization (L10N/I18N) 2–19
2.5.2.1 Determining the active Locale 2–19
2.5.2.2 Determining the Character Encoding 2–20
2.5.2.3 Localized Text 2–20
Contents x
3.1.12 Component Specialization Methods 3–12
3.1.13 Lifecycle Management Methods 3–14
3.1.14 Utility Methods 3–15
3.2 Component Behavioral Interfaces 3–16
3.2.1 ActionSource 3–16
3.2.1.1 Properties 3–17
3.2.1.2 Methods 3–17
3.2.1.3 Events 3–18
3.2.2 ActionSource2 3–18
3.2.2.1 Properties 3–19
3.2.2.2 Methods 3–19
3.2.2.3 Events 3–19
3.2.3 NamingContainer 3–19
3.2.4 StateHolder 3–20
3.2.4.1 Properties 3–20
3.2.4.2 Methods 3–20
3.2.4.3 Events 3–21
3.2.5 ValueHolder 3–21
3.2.5.1 Properties 3–22
3.2.5.2 Methods 3–22
3.2.5.3 Events 3–22
3.2.6 EditableValueHolder 3–23
3.2.6.1 Properties 3–23
3.2.6.2 Methods 3–24
3.2.6.3 Events 3–25
3.2.7 SystemEventListenerHolder 3–25
3.2.7.1 Properties 3–25
3.2.7.2 Methods 3–25
Contents xii
3.6.1.1 What does it mean to be a JSF User Interface component?
3–42
3.6.1.2 How does one make a custom JSF User Interface component
(JSF 1.2 and earlier)? 3–43
3.6.1.3 How does one make a composite component? 3–44
3.6.1.4 A simple composite component example 3–45
3.6.1.5 Walk through of the run-time for the simple composite
component example 3–47
3.6.1.6 Composite Component Terms 3–48
3.6.2 Composite Component Metadata 3–49
Contents xiv
4.1.10 UIPanel 4–19
4.1.10.1 Component Type 4–19
4.1.10.2 Properties 4–19
4.1.10.3 Methods 4–19
4.1.10.4 Events 4–19
4.1.11 UIParameter 4–20
4.1.11.1 Component Type 4–20
4.1.11.2 Properties 4–20
4.1.11.3 Methods 4–20
4.1.11.4 Events 4–20
4.1.12 UISelectBoolean 4–21
4.1.12.1 Component Type 4–21
4.1.12.2 Properties 4–21
4.1.12.3 Methods 4–21
4.1.12.4 Events 4–21
4.1.13 UISelectItem 4–22
4.1.13.1 Component Type 4–22
4.1.13.2 Properties 4–22
4.1.13.3 Methods 4–23
4.1.13.4 Events 4–23
4.1.14 UISelectItems 4–24
4.1.14.1 Component Type 4–24
4.1.14.2 Properties 4–24
4.1.14.3 Methods 4–24
4.1.14.4 Events 4–25
4.1.15 UISelectMany 4–26
4.1.15.1 Component Type 4–26
4.1.15.2 Properties 4–26
Contents xvi
5.1 Value Expressions 5–2
5.1.1 Overview 5–2
5.1.2 Value Expression Syntax and Semantics 5–3
5.2 MethodExpressions 5–3
5.2.1 MethodExpression Syntax and Semantics 5–5
5.3 The Managed Bean Facility 5–5
5.3.1 Managed Bean Configuration Example 5–10
5.4 Leveraging Java EE 5 Annotations in Managed Beans 5–13
5.4.1 Managed Bean Lifecycle Annotations 5–14
5.5 How Faces Leverages the Unified EL 5–15
5.5.1 ELContext 5–15
5.5.1.1 Lifetime, Ownership and Cardinality 5–15
5.5.1.2 Properties 5–16
5.5.1.3 Methods 5–16
5.5.1.4 Events 5–16
5.5.2 ELResolver 5–16
5.5.2.1 Lifetime, Ownership, and Cardinality 5–17
5.5.2.2 Properties 5–17
5.5.2.3 Methods 5–17
5.5.2.4 Events 5–18
5.5.3 ExpressionFactory 5–18
5.5.3.1 Lifetime, Ownership, and Cardinality 5–18
5.5.3.2 Properties 5–18
5.5.3.3 Methods 5–19
5.5.3.4 Events 5–19
5.6 ELResolver Instances Provided by Faces 5–19
5.6.1 Faces ELResolver for Markup Pages 5–20
5.6.1.1 Faces Implicit Object ELResolver for Markup Pages 5–21
Contents xviii
6. Per-Request State Information 6–1
6.1 FacesContext 6–1
6.1.1 Application 6–1
6.1.2 Attributes 6–2
6.1.3 ELContext 6–2
6.1.4 ExternalContext 6–2
6.1.5 ViewRoot 6–5
6.1.6 Message Queue 6–5
6.1.7 RenderKit 6–6
6.1.8 ResponseStream and ResponseWriter 6–6
6.1.9 Flow Control Methods 6–7
6.1.10 Partial Processing Constants And Methods 6–8
6.1.11 Access To The Current FacesContext Instance 6–9
6.1.12 CurrentPhaseId 6–10
6.2 FacesMessage 6–10
6.3 ResponseStream 6–11
6.4 ResponseWriter 6–11
6.5 FacesContextFactory 6–13
Contents xx
7.9.4 Acquiring MethodBinding Instances 7–30
7.9.5 Object Factories 7–30
7.9.6 StateManager 7–31
7.9.7 ResponseStateManager 7–31
Contents xxii
Attributes 9–26
Constraints 9–26
Description 9–26
9.4.6 <f:facet> 9–28
Syntax 9–28
Body Content 9–28
Attributes 9–28
Constraints 9–28
Description 9–28
9.4.7 <f:loadBundle> 9–29
Syntax 9–29
Body Content 9–29
Attributes 9–29
Constraints 9–29
Description 9–29
9.4.8 <f:param> 9–30
Syntax 9–30
Body Content 9–30
Attributes 9–30
Constraints 9–30
Description 9–31
9.4.9 <f:phaseListener> 9–32
Syntax 9–32
Body Content 9–32
Attributes 9–32
Constraints 9–32
Description 9–32
9.4.10 <f:selectItem> 9–34
Contents xxiv
Description 9–45
9.4.15 <f:validateLength> 9–46
Syntax 9–46
Body Content 9–46
Attributes 9–46
Constraints 9–46
Description 9–47
9.4.16 <f:validateLongRange> 9–48
Syntax 9–48
Body Content 9–48
Attributes 9–48
Constraints 9–48
Description 9–49
9.4.17 <f:validator> 9–50
Syntax 9–50
Body Content 9–50
Attributes 9–50
Constraints 9–50
Description 9–50
9.4.18 <f:valueChangeListener> 9–52
Syntax 9–52
Body Content 9–52
Attributes 9–52
Constraints 9–52
Description 9–52
9.4.19 <f:verbatim> 9–54
Syntax 9–54
Body Content 9–54
Contents xxvi
11.1 Web Application Deployment Descriptor 11–1
11.1.1 Servlet Definition 11–2
11.1.2 Servlet Mapping 11–2
11.1.3 Application Configuration Parameters 11–3
11.2 Included Classes and Resources 11–4
11.2.1 Application-Specific Classes and Resources 11–5
11.2.2 Servlet and JSP API Classes (javax.servlet.*) 11–5
11.2.3 JSP Standard Tag Library (JSTL) API Classes (javax.servlet.jsp.jstl.*)
11–5
11.2.4 JSP Standard Tag Library (JSTL) Implementation Classes 11–5
11.2.5 JavaServer Faces API Classes (javax.faces.*) 11–5
11.2.6 JavaServer Faces Implementation Classes 11–6
11.2.6.1 FactoryFinder 11–6
11.2.6.2 FacesServlet 11–7
11.2.6.3 UIComponentELTag 11–9
11.2.6.4 FacetTag 11–9
11.2.6.5 ValidatorTag 11–9
11.3 Deprecated APIs in the webapp package 11–9
11.3.1 AttributeTag 11–9
11.3.2 ConverterTag 11–9
11.3.3 UIComponentBodyTag 11–10
11.3.4 UIComponentTag 11–10
11.3.5 ValidatorTag 11–10
11.4 Application Configuration Resources 11–10
11.4.1 Overview 11–10
11.4.2 Application Startup Behavior 11–11
11.4.3 Application Configuration Resource Format 11–12
11.4.4 Configuration Impact on JSF Runtime 11–13
11.4.5 Delegating Implementation Support 11–15
Contents xxviii
13.3.4.1 Use Case 13–9
13.4 Partial View Traversal 13–9
13.4.1 Partial View Execute 13–10
13.4.2 Partial View Render 13–11
13.4.3 Sending The Response to The Client 13–11
Contents xxx
xxxi JavaServer Faces Specification • September 2008
Preface
This is the JavaServer Faces 2.0 (JSF 2.0) specification, developed by the JSR-314 expert
group under the Java Community Process (see <http://www.jcp.org> for more information
about the JCP).
Preface 1
Section 2.2.1 “Restore View”
Modified to indicate that the AfterAddToParent event must be sent after the view was
created. Also specify that if the PDL is Facelets, the tree must be fully constructed before
exiting Restore View.
Added the requirement for (partial requests) to prevent writing to the response at the start of
this phase (to prevent content from being written outside f:view)
Preface 3
Section 3.1.10 “Generic Attributes”
Described additional responsibilities for Map get() method if the component instance is a
composite component.
Moved existing event content to be in new subsection: Section 3.4.2 “Application Events”,
and created a new subsection Section 3.4.3 “System Events”
Preface 5
Section 4.1.17.2 “Properties”
Specify the viewMap property on UIViewRoot.
Preface 7
Section 6.1.8 “ResponseStream and ResponseWriter”
Add FacesContext enableResponseWriting method.
Modify getActionURL() to remove the use of DEFAULT_SUFFIX and instead take a simpler
implementation.
Preface 9
Section “Facelets and its use in Web Applications”
New chapter insterted after Chapter 9, titled, “Integration with Facelets”. This implies
increasing the remaining chapter numbers by one.
New javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL
ServletContext init param.
Preface 11
Section 13.3.1 “Collecting and Encoding View State”
This section describes the process of collecting and encoding form view state that will be
sent to the server - a common operation for JavaServer Faces Ajax frameworks.
Preface 13
Standard HTML RenderKit specification
General Changes
The numbers in the text below refer to issue numbers in the issue tracker found at
<https://javaserverfaces-spec-public.dev.java.net/servlets/ProjectIssues>.
■ 100 - New methods on RenderKit: getComponentFamilies() and
getRendererTypes().
■ 170 - Allow commandButton to have f:param children.
■ 175 - Non-normatively clarify that the value of the "src" attribute will have the context-
root prepended to it if the value starts with "/".
Therefore, a JSF container must support all of the above specifications. This requirement
allows faces applications to be portable across a variety of JSF implementations.
In addition, JSF is designed to work synergistically with other web-related Java APIs,
including:
■ Portlet Specification, 1.0 JSR-168 <http://www.jcp.org/jsr/detail/168.jsp>
■ Portlet Specification, 2.0 JSR-286 <http://www.jcp.org/jsr/detail/286.jsp>
■ JSF Portlet Bridge Specification, JSR-301 <http://www.jcp.org/jsr/detail/301.jsp>
Preface 15
Related Documents and Specifications
The following documents and specifications of the World Wide Web Consortium will be of
interest to JSF implementors, as well as developers of applications and components based on
JavaServer Faces.
■ Hypertext Markup Language (HTML), version 4.01 <http://www.w3.org/TR/html4/>
■ Extensible HyperText Markup Language (XHTML), version 1.0
<http://www.w3.org/TR/xhtml1>
■ Extensible Markup Language (XML), version 1.0 (Second Edition)
<http://www.w3.org/TR/REC-xml>
The class and method Javadoc documentation for the classes and interfaces in
javax.faces (and its subpackages) are incorporated by reference as requirements of this
Specification.
The JSP tag library for the HTML_BASIC standard RenderKit is specified in the TLDDocs
and incorporated by reference in this Specification.
Terminology
The key words MUST, MUST NOT, REQUIRED, SHALL, SHALL NOT, SHOULD,
SHOULD NOT, RECOMMENDED, MAY, and OPTIONAL in this document are to be
interpreted as described in
■ Key words for use in RFCs to Indicate Requirement Levels (RFC 2119) <http://www.rfc-
editor.org/rfc/rfc2119.txt>
Providing Feedback
We welcome any and all feedback about this specification. Please email your comments to
<[email protected]>.
Please note that, due to the volume of feedback that we receive, you will not normally
receive a reply from an engineer. However, each and every comment is read, evaluated, and
archived by the specification team.
Acknowledgements
The JavaServer Faces Specification (version 2.0) is the result of the diligent efforts of the
JSR-314 Expert Group, working under the auspices of the Java Community Process.
Overview
JavaServer Faces (JSF) is a user interface (UI) framework for Java web applications. It is
designed to significantly ease the burden of writing and maintaining applications that run on
a Java application server and render their UIs back to a target client. JSF provides ease-of-
use in the following ways:
■ Makes it easy to construct a UI from a set of reusable UI components
■ Simplifies migration of application data to and from the UI
■ Helps manage UI state across server requests
■ Provides a simple model for wiring client-generated events to server-side application code
■ Allows custom UI components to be easily built and re-used
Most importantly, JSF establishes standards which are designed to be leveraged by tools to
provide a developer experience which is accessible to a wide variety of developer types,
ranging from corporate developers to systems programmers. A “corporate developer” is
characterized as an individual who is proficient in writing procedural code and business
logic, but is not necessarily skilled in object-oriented programming. A “systems
programmer” understands object-oriented fundamentals, including abstraction and designing
for re-use. A corporate developer typically relies on tools for development, while a system
programmer may define his or her tool as a text editor for writing code.
Therefore, JSF is designed to be tooled, but also exposes the framework and programming
model as APIs so that it can be used outside of tools, as is sometimes required by systems
programmers.
Page authors will generally assemble the content of the pages being created from libraries of
prebuilt user interface components that are provided by component writers, tool providers,
and JSF implementors. The components themselves will be represented as configurable
objects that utilize the dynamic markup capabilities of the underlying rendering technology.
When JavaServer Pages are in use, for example, components will be represented as JSP
custom actions, which will support configuring the attributes of those components as custom
Page authors will generally utilize development tools, such as HTML editors, that allow them
to deal directly with the visual representation of the page being created. However, it is still
feasible for a page author that is familiar with the underlying rendering technology to
construct pages “by hand” using a text editor.
The component writer role is sometimes separate from other JSF roles, but is often
combined. For example, reusable components, component libraries, and render kits might be
created by:
■ A page author creating a custom “widget” for use on a particular page
■ An application developer providing components that correspond to specific data objects in
the application’s business domain
■ A specialized team within a larger development group responsible for creating
standardized components for reuse across applications
■ Third party library and framework providers creating component libraries that are portable
across JSF implementations
■ Tool providers whose tools can leverage the specific capabilities of those libraries in
development of JSF-based applications
■ JSF implementors who provide implementation-specific component libraries as part of
their JSF product suite
Only the latter responsibility is directly related to JavaServer Faces APIs. In particular, the
following steps are required to fulfill this responsibility:
■ Expose the underlying data required by the user interface layer as objects that are
accessible from the web tier (such as via request or session attributes in the Servlet API),
via value reference expressions, as described in Chapter 4 “Standard User Interface
Components.”
■ Provide application-level event handlers for the events that are enqueued by JSF
components during the request processing lifecycle, as described in Section 2.2.5 “Invoke
Application”.
Application modules interact with JSF through standard APIs, and can therefore be created
using new and existing tools that facilitate general Java development. In addition, application
modules can be written (either by hand, or by being generated) in conformance to an
application framework created by a tool provider.
Tool providers will generally leverage the JSF APIs for introspection of the features of
component libraries and render kit frameworks, as well as the application portability implied
by the use of standard APIs in the code generated for an application.
Advanced features of the JSF APIs allow JSF implementors, as well as application
developers, to customize and extend the basic functionality of JSF in a portable way. These
features provide a rich environment for server vendors to compete on features and quality of
service aspects of their implementations, while maximizing the portability of JSF-based
applications across different JSF implementations.
Web user interfaces generally follow a pattern where the user-agent sends one or more
requests to the server with the end goal of displaying a user-interface. In the case of Web
browsers, an initial HTTP GET or POST request is made to the server, which responds with
a document which the browser interprets and automatically makes subsequent requests on the
user’s behalf. The responses to each of these subsequent requests are usually images,
JavaScript files, CSS Style Sheets, and other artifacts that fit “into” the original document. If
the JSF lifecycle is involved in rendering the initial response, the entire process of initial
request, the response to that request, and any subsequent requests made automatically by the
user-agent, and their responses, is called a Faces View Request/Response for discussion. The
following graphic illustrates a Faces View Request/Response.
In addition, of course, your web application may receive non-Faces requests that generate
non-Faces responses. Because such requests do not involve JavaServer Faces at all, their
processing is outside the scope of this specification, and will not be considered further.
READER NOTE: The dynamic behavior descriptions in this Chapter make forward
references to the sections that describe the individual classes and interfaces. You will
probably find it useful to follow the reference and skim the definition of each new class or
interface as you encounter them, then come back and finish the behavior description. Later,
you can study the characteristics of each JSF API in the subsequent chapters.
The “Handle Resource Request” box, and its subsequent boxes, are explained in Section 2.6
“Resource Handling”. The following diagram explains the “Execute and Render Lifecycle”
box.
The behavior of the individual phases of the request processing lifecycle are described in
individual subsections of Section 2.2 “Standard Request Processing Lifecycle Phases”. Note
that, at the conclusion of several phases of the request processing lifecycle, common event
processing logic (as described in Section 2.3 “Common Event Processing”) is performed to
broadcast any FacesEvents generated by components in the component tree to interested
event listeners.
In any of these scenarios, the application will have used the standard mechanisms of the
servlet or portlet API to create the response headers and content. It is then necessary to tell
the JSF implementation that the response has already been created, so that the Render
Response phase of the request processing lifecycle should be skipped. This is accomplished
by calling the responseComplete() method on the FacesContext instance for the
current request, prior to returning from event handlers or application actions.
The implementation for this phase must not derive a new view identifier based on the servlet
mapping. This must be delegated to the default ViewHandler implementation. See
Section 7.5.2 “Default ViewHandler Implementation”.
During the decoding of request values, some components perform special processing,
including:
■ Components that implement ActionSource (such as UICommand), which recognize
that they were activated, will queue an ActionEvent. The event will be delivered at the
end of Apply Request Values phase if the immediate property of the component is
true, or at the end of Invoke Application phase if it is false.
■ Components that implement EditableValueHolder (such as UIInput), and whose
immediate property is set to true, will cause the conversion and validation processing
(including the potential to fire ValueChangeEvent events) that normally happens
during Process Validations phase to occur during Apply Request Values phase instead.
If any of the decode() methods that were invoked, or an event listener that processed a
queued event, called responseComplete() on the FacesContext instance for the
current request, clear the remaining events from the event queue and terminate lifecycle
processing of the current request. [P1-start-applyRequestComplete]If any of the decode()
methods that were invoked, or an event listener that processed a queued event, called
renderResponse() on the FacesContext instance for the current request, clear the
remaining events from the event queue and transfer control to the Render Response phase of
the request processing lifecycle. Otherwise, control must proceed to the Process Validations
phase.[P1-end]
During the processing of validations, events may have been queued by the components
and/or Validators whose validate() method was invoked. As described in Section 2.3
“Common Event Processing”, the processValidators() method on the UIViewRoot
component at the root of the component tree will have caused any queued events to be
broadcast to interested listeners.
At the end of this phase, all conversions and configured validations will have been
completed. Conversions and Validations that failed will have caused messages to be
enqueued via calls to the addMessage() method of the FacesContext instance for the
current request, and the valid property on the corresponding components will have been set
to false.
If any of the validate() methods that were invoked, or an event listener that processed a
queued event, called responseComplete() on the FacesContext instance for the
current request, clear the remaining events from the event queue and terminate lifecycle
processing of the current request. [P1-start-validationValidate]If any of the validate()
methods that were invoked, or an event listener that processed a queued event, called
renderResponse() on the FacesContext instance for the current request, clear the
remaining events from the event queue and transfer control to the Render Response phase of
the request processing lifecycle. Otherwise, control must proceed to the Update Model
Values phase.[P1-end]
[P1-start-updateModel]During the Update Model Values phase, the JSF implementation must
call the processUpdates() method of the UIViewRoot component of the tree.[P1-
end] This will normally cause the processUpdates() method of each component in the
tree to be called recursively, as described in the API reference for the
UIComponent.processUpdates() method. [P1-start-partialUpdate] The
processUpdates() method must determine if the current request is a “partial request”
by calling FacesContext.isAjaxRequest(). If
FacesContext.isAjaxRequest() returns true, perform the sequence of steps as
outlined in Section 2.2.4.1 “Update Model Values Partial Processing”. [P1-end]The actual
model update for a particular component is done in the updateModel() method for that
component.
During the processing of model updates, events may have been queued by the components
whose updateModel() method was invoked. As described in Section 2.3 “Common Event
Processing”, the processUpdates() method on the UIViewRoot component at the root
of the component tree will have caused any queued events to be broadcast to interested
listeners.
At the end of this phase, all appropriate model data objects will have had their values
updated to match the local value of the corresponding component, and the component local
values will have been cleared.
If any of the updateModel() methods that were invoked, or an event listener that
processed a queued event, called responseComplete() on the FacesContext instance
for the current request, clear the remaining events from the event queue and terminate
lifecycle processing of the current request. [P1-start-updateModelComplete]If any of the
updateModel() methods that was invoked, or an event listener that processed a queued
event, called renderResponse() on the FacesContext instance for the current
request, clear the remaining events from the event queue and transfer control to the Render
Response phase of the request processing lifecycle. Otherwise, control must proceed to the
Invoke Application phase.[P1-end]
2. Causes the state of the response to be saved for processing on subsequent requests.
JSF supports a range of approaches that JSF implementations may utilize in creating the
response text that corresponds to the contents of the response view, including:
■ Deriving all of the response content directly from the results of the encoding methods (on
either the components or the corresponding renderers) that are called.
■ Interleaving the results of component encoding with content that is dynamically generated
by application programming logic.
■ Interleaving the results of component encoding with content that is copied from a static
“template” resource.
■ Interleaving the results of component encoding by embedding calls to the encoding
methods into a dynamic resource (such as representing the components as custom tags in
a JSP page).
1. Typically, component selection will be driven by the occurrence of special markup (such as the existence of a JSP
custom tag) in the template text associated with the component tree.
2. For example, this technique is used when custom tags in JSP pages are utilized as the rendering technology, as described
in Chapter 9 “Integration with JSP.
Upon completion of rendering, the completed state of the view must have been saved using
the methods of the class StateManager. This state information must be made accessible
on a subsequent request, so that the Restore View can access it.[P1-end] For more on
StateManager, see Section 7.6.3 “State Saving Methods.”
During several phases of the request processing lifecycle, as described in Section 2.2
“Standard Request Processing Lifecycle Phases”, the possibility exists for events to be
queued (via a call to the queueEvent() method on the source UIComponent instance, or
a call to the queue() method on the FacesEvent instance), which must now be broadcast
to interested event listeners. The broadcast is performed as a side effect of calling the
appropriate lifecycle management method (processDecodes(),
processValidators(), processUpdates(), or processApplication()) on the
UIViewRoot instance at the root of the current component tree.
It is also possible for event listeners to cause additional events to be enqueued for processing
during the current phase of the request processing lifecycle. [P1-start-eventOrder]Such
events must be broadcast in the order they were enqueued, after all originally queued events
have been broadcast, before the lifecycle management method returns.[P1-end]
where the context, request, and response objects represent the corresponding
instances for the application environment.[P1-end] For example, in a servlet-based
application, these would be the ServletContext, HttpServletRequest, and
HttpServletResponse instances for the current request.
As described in Chapter 8, changing the RenderKit being used changes the set of
Renderers that will actually perform decoding and encoding activities. Because the
components themselves store only a rendererType property (a logical identifier of a
particular Renderer), it is thus very easy to switch between RenderKits, as long as they
support renderers with the same renderer types.
This application’s default locale is en, but it also supports de, fr, and es locales. These
elements cause the Application instance to be populated with Locale data. Please see
the javadocs for details.
The UIViewRoot’s Locale is determined and set by the ViewHandler during the
execution of the ViewHandler’s createView() method. [P1-start-locale]This method
must cause the active Locale to be determined by looking at the user’s preferences
combined with the application’s stated supported locales.[P1-end] Please see the javadocs for
details.
The application can call UIViewRoot.setLocale() directly, but it is also possible for
the page author to override the UIViewRoot’s locale by using the locale attribute on the
<f:view> tag. [P1-start-localeValue]The value of this attribute must be specified as
language[{-|_}country[{-|_}variant]] without the colons, for example
"ja_JP_SJIS". The separators between the segments must be '-' or '_'.[P1-end]
In all cases where JSP is utilized, the active Locale is set under “request scope” into the
JSTL class javax.servlet.jsp.jstl.core.Config, under the key
Config.FMT_LOCALE.
On an initial request to a Faces webapp, the request character encoding is left unmodified,
relying on the underlying request object (e.g., the servlet or portlet request) to parse request
parameter correctly.
[P1-start-encoding]At the end of the render-response phase, the ViewHandler must store the
response character encoding used by the underlying response object (e.g., the servlet or
portlet response) in the session (if and only if a session already exists) under a well known,
implementation-dependent key.
On a subsequent postback, before any of the ExternalContext methods for accessing request
parameters are invoked, the ViewHandler must examine the Content-Type header to read the
charset attribute and use its value to set it as the request encoding for the underlying request
object. If the Content-Type header doesn't contain a charset attribute, the encoding previously
stored in the session (if and only if a session already exists), must be used to set the encoding
for the underlying request object. If no character encoding is found, the request encoding
must be left unmodified.[P1-end]
The above algorithm allows an application to use the mechanisms of the underlying
technologies to adjust both the request and response encoding in an application-specific
manner, for instance using the page directive with a fixed character encoding defined in the
contentType attribute in a JSP page, see the Servlet, Portlet and JSP specifications for details.
Note, though, that the character encoding rules prior to Servlet 2.4 and JSP 2.0 are imprecise
and special care must be taken for portability between containers.
Since most JSF components allow pulling their display value from the model tier, it is easy
to do the localization at the model tier level. As a convenience, JSF provides the
<f:loadBundle> tag, which takes a ResourceBundle and loads it into a Map, which is
then stored in the scoped namespace in request scope, thus making its messages available
using the same mechanism for accessing data in the model tier. For example:
<f:loadBundle basename=”com.foo.industryMessages.chemical”
A JSF application may provide its own messages, or overrides to the standard messages by
supplying a <message-bundle> element to in the application configuration resources.
Since the ResourceBundle provided in the Java platform has no notion of summary or
detail, JSF adopts the policy that ResourceBundle key for the message looks up the
message summary. The detail is stored under the same key as the summary, with _detail
appended. [P1-start-bundleKey]These ResourceBundle keys must be used to look up the
necessary values to create a localized FacesMessage instance. Note that the value of the
summary and detail keys in the ResourceBundle may contain parameter substitution
tokens, which must be substituted with the appropriate values using
java.text.MessageFormat.[P1-end] Replace the last parameter substitution token
shown in the messages above with the input component’s label attribute. For example,
{1} for “DoubleRangeValidator.MAXIMUM”, {2} for
“ShortConverter.SHORT”. The label attribute is a generic attribute. Please see
Section 3.1.10 “Generic Attributes” and Section 8.5 “Standard HTML RenderKit
Implementation” for more information on these attributes. If the input component’s label
attribute is not specified, use the component’s client identifier.
These messages can be displayed in the page using the UIMessage and UIMessages
components and their corresponding tags, <h:message> and <h:messages>.
A custom component that does extend from one of the standard components and maintains
its own state, in addition to the state maintained by the superclass must take special care to
implement StateHolder correctly. [P1-start-saveState]Notably, calls to saveState()
must not alter the state in any way.[P1-end] The subclass is responsible for saving and
restoring the state of the superclass. Consider this example. My custom component
represents a “slider” ui widget. As such, it needs to keep track of the maximum value,
minimum value, and current values as part of its state.
resources/<resourceIdentifier>
relative to the web app root. Resources packaged into the web app root must be accessed
using the getResource*() methods on ExternalContext.[P1-end]
META-INF/resources/<resourceIdentifier>
[localePrefix/][libraryName/][libraryVersion/]resourceName[/reso
urceVersion]
[P1-end]
The following examples illustrate the nine valid combinations of the above resource
identifier segments.
library
resource
localePrefx libraryName Version resourceName
Version Description actual resourceIdentifier
[optional] [optional] [optional [required]
[optional]
]
A non-localized, non-
versioned image
duke.gif resource called duke.gif
"duke.gif", not in a
library
function getLocalePrefix() {
var localePrefix;
var appBundleName = facesContext.application.messageBundle;
if (null != appBundleName) {
var locale =
facesContext.application.viewHandler.calculateLocale();
ResourceBundle appBundle = ResourceBundle.getBundle(
appBundleName, locale);
localePrefix = appBundle.getString(ResourceHandler.
[P1-end]
These entries render exactly the same markup. In addition to using the name and library
attributes, stylesheet and script resources can be “relocated” to other parts of the view. For
example, we could specify that a script resource be rendered within an HTML “head”,
“body” or “form” element in the page.
@ListenerFor(facesEventClass=AfterAddToParentEvent.class,
sourceClass=UIOutput.class)
public class ScriptRenderer extends Renderer implements
ComponentSystemEventListener {...
Refer to Section 3.4 “Event and Listener Model”. When the component for this resource is
added to the view, the ScriptRenderer processEvent method adds the component to a
facet (named by the target attribute) under the view root. using the UIViewRoot
component resource methods as described in Section 4.1.17.3 “Methods”.
The <h:head> and <h:body> tags refer to the renderers HeadRenderer and BodyRenderer
respectively, described in Section 8.5 “Standard HTML RenderKit Implementation”. During
the rendering phase, the encode methods for these renderers render all component resources
under the facet child (named by target) under the UIViewRoot using the UIViewRoot
component resource methods as described in Section 4.1.17.3 “Methods”.
Existing component libraries (with existing head and body components), that want to use this
resource loading feature must follow the rendering requirements described in Section 8.5
“Standard HTML RenderKit Implementation”.
A JSF user interface component is the basic building block for creating a JSF user interface.
A particular component represents a configurable and reusable element in the user interface,
which may range in complexity from simple (such as a button or text field) to compound
(such as a tree control or table). Components can optionally be associated with corresponding
objects in the data model of an application, via value expressions.
JSF also supports user interface components with several additional helper APIs:
■ Converters—Pluggable support class to convert the markup value of a component to and
from the corresponding type in the model tier.
■ Events and Listeners—An event broadcast and listener registration model based on the
design patterns of the JavaBeans Specification, version 1.0.1.
■ Validators—Pluggable support classes that can examine the local value of a component
(as received in an incoming request) and ensure that it conforms to the business rules
enforced by each Validator. Error messages for validation failures can be generated and
sent back to the user during rendering.
The user interface for a particular page of a JSF-based web application is created by
assembling the user interface components for a particular request or response into a view.
The view is a tree of classes that implement UIComponent. The components in the tree
have parent-child relationships with other components, starting at the root element of the
tree, which must be an instance of UIViewRoot. Components in the tree can be anonymous
or they can be given a component identifier by the framework user. Components in the tree
can be located based on component identifiers, which must be unique within the scope of the
nearest ancestor to the component that is a naming container. For complex rendering
scenarios, components can also be attached to other components as facets.
This chapter describes the basic architecture and APIs for user interface components and the
supporting APIs.
Component writers, tool providers, application developers, and JSF implementors can also
create additional UIComponent implementations for use within a particular application. To
assist such developers, a convenience subclass,
javax.faces.component.UIComponentBase, is provided as part of JSF. This class
provides useful default implementations of nearly every UIComponent method, allowing
the component writer to focus on the unique characteristics of a particular UIComponent
implementation.
The following subsections define the key functional capabilities of JSF user interface
components.
If a component has been given an identifier, it must be unique in the namespace of the closest
ancestor to that component that is a NamingContainer (if any).
Component types starting with “javax.faces.” are reserved for use by the JSF specification.
Each standard user interface component class has a standard value for the component family,
which is used to look up renderers associated with this component. Subclasses of a generic
UIComponent class will generally inherit this property from its superclass, so that renderers
who only expect the superclass will still be able to process specialized subclasses.
Component families starting with “javax.faces.” are reserved for use by the JSF specification.
Value binding expressions are managed with the following method calls:
where name is the name of the attribute or property for which to establish the value
expression. [P1-start setValueExpression rules] The implementation of
setValueExpression must detemine if the expression is a literal by calling
ValueExpression.isLiteralText() on the expression argument. If the
In previous versions of this specification, this concept was called “value binding”. Methods
and classes referring to this concept are deprecated, but remain implemented to preserve
backwards compatibility.
Please consult the javadoc for these methods to learn how they are implemented in terms of
the new “value expression” concept.
The client identifier is derived from the component identifier (or the result of calling
UIViewRoot.createUniqueId() if there is not one), and the client identifier of the
closest parent component that is a NamingContainer according to the algorithm specified
in the javadoc for UIComponent.getClientId(). The Renderer associated with this
component, if any, will then be asked to convert this client identifier to a form appropriate
for sending to the client. The value returned from this method must be the same throughout
the lifetime of the component instance unless setId() is called, in which case it will be
recalculated by the next call to getClientId().
Components that have been added as children of another component can identify the parent
by calling the getParent method. For the root node component of a component tree, or
any component that is not part of a component tree, getParent will return null. In some
special cases, such as transient components, it is possible that a component in the tree will
return null from getParent(). The setParent() method should only be called by the
Return a mutable List that contains all of the child UIComponents for this component
instance. [P1-start requirements of UIComponent.getChildren() ] The returned List
implementation must support all of the required and optional methods of the List interface,
as well as update the parent property of children that are added and removed, as described in
the Javadocs for this method. [P1-end] Note that the add() methods have a special
requirement to cause the AfterAddToParent method to be fired, as well as the processing
of the ResourceDependency annotation. See the javadocs for getChildren() for
details.
A convenience method to return the number of child components for this component. [P2-
start UIComponent.getChildCount requirements.] If there are no children, this method must
return 0. The method must not cause the creation of a child component list, so it is preferred
over calling getChildren().size() when there are no children. [P2-end]
Search for and return the UIComponent with an id that matches the specified search
expression (if any), according to the algorithm described in the Javadocs for this method.
Return an immutable Iterator over all of the facets associated with this component (in an
undetermined order), followed by all the child components associated with this component
(in the order they would be returned by getChildren())..
To meet this requirement, JavaServer Faces components offer support for facets, which
represent a named collection of subordinate (but non-child) components that are related to
the current component by virtue of a unique facet name that represents the role that particular
component plays. Although facets are not part of the parent-child tree, they participate in
request processing lifecycle methods, as described in Section 3.1.13 “Lifecycle Management
Methods”.
Return a mutable Map representing the facets of this UIComponent, keyed by the facet name.
For easy use of components that use facets, component authors may include type-safe getter
and setter methods that correspond to each named facet that is supported by that component
class. For example, a component that supports a header facet of type UIHeader should
have methods with signatures and functionality as follows:
The attributes for a component may be of any Java programming language object type, and
are keyed by attribute name (a String). However, see Section 7.6.2 “State Saving Alternatives
and Implications” for implications of your application’s choice of state saving method on the
classes used to implement attribute values.
Attribute names that begin with javax.faces are reserved for use by the JSF
specification. Names that begin with javax are reserved for definition through the Java
Community Process. Implementations are not allowed to define names that begin with
javax.
The Map returned by getAttributes() must also conform to the entire contract for the
Map interface. [P1-end]
UIComponent Constants
This is used as a key in the FacesContext attributes Map to indicate the component that
is currently being processed.
This is used as a key in the FacesContext attributes Map to indicate the composite
component that is currently being processed.
rendererType RW String Identifier of the Renderer instance (from the set of Renderer
instances supported by the RenderKit associated with the
component tree we are processing. If this property is set, several
operations during the request processing lifecycle (such as decode
and the encodeXxx family of methods) will be delegated to a
Renderer instance of this type. If this property is not set, the
component must implement these methods directly.
rendersChildr RO boolean A flag that, if set to true, indicates that this component manages
en the rendering of all of its children components (so the JSF
implementation should not attempt to render them). The default
implementation in UIComponentBase delegates this setting to
the associated Renderer, if any, and returns false otherwise.
transient RW boolean A flag that, if set to true, indicates that this component must not
be included in the state of the component tree. The default
implementation in UIComponentBase returns false for this
property.
The method names for the render-independent property getters and setters must conform to
the design patterns in the JavaBeans specification. See Section 7.6.2 “State Saving
Alternatives and Implications” for implications of your application’s choice of state saving
method on the classes used to implement property values.
The broadcast() method is called during the common event processing (see Section 2.3
“Common Event Processing”) at the end of several request processing lifecycle phases. For
more information about the event and listener model, see Section 3.4 “Event and Listener
Model”. Note that it is not necessary to override this method to support additional event
types.
These methods are called during the Render Response phase of the request processing
lifecycle. encodeAll() will cause this component and all its children and facets that return
true from isRendered() to be rendered, regardless of the value of the
getRendersChildren() return value. encodeBegin(), encodeChildren(), and
encodeEnd()have the responsibility of creating the response data for the beginning of this
component, this component’s children (only called if the rendersChildren property of
this component is true), and the ending of this component, respectively. Typically, this will
involve generating markup for the output technology being supported, such as creating an
HTML <input> element for a UIInput component. For clients that support it, the encode
methods might also generate client-side scripting code (such as JavaScript), and/or
stylesheets (such as CSS). The default implementations in UIComponentBase
encodeBegin() and encodeEnd() delegate to a corresponding Renderer, if the
rendererType property is true, and do nothing otherwise. [P1-start-comp-special]The
default implementation in UIComponentBase encodeChildren() must iterate over its
children and call encodeAll() for each child component. encodeBegin() must
publish a BeforeRenderEvent.[P1-end]
Enqueue the specified event for broadcast at the end of the current request processing
lifecycle phase. Default behavior is to delegate this to the queueEvent() of the parent
component, normally resulting in broadcast via the default behavior in the UIViewRoot
lifecycle methods.
In order to support the “component” implicit object (See Section 5.6.2.1 “Implicit Object
ELResolver for Programmatic Access”), the following methods have been added to
UIComponent
Perform the component tree processing required by the Restore View phase of the request
processing lifecycle for all facets of this component, all children of this component, and this
component itself.
Perform the component tree processing required by the Apply Request Values phase of the
request processing lifecycle for all facets of this component, all children of this component,
and this component itself
Perform the component tree processing required by the Update Model Values phase of the
request processing lifecycle for all facets of this component, all children of this component,
and this component itself.
Perform the component tree processing required by the state saving portion of the Render
Response phase of the request processing lifecycle for all facets of this component, all
children of this component, and this component itself.
Return the Renderer that is associated this UIComponent, if any, based on the values of
the family and rendererType properties currently stored as instance data on the
UIComponent.
These methods are used to register and deregister an event listener. They should be called
only by a public addXxxListener() method on the component implementation class, which
provides typesafe listener registration.
3.2.1 ActionSource
The ActionSource interface defines a way for a component to indicate that wishes to be a
source of ActionEvent events, including the ability invoke application actions (see
Section 7.3 “Application Actions”) via the default ActionListener facility (see
Section 7.1.1 “ActionListener Property”).
3.2.1.2 Methods
ActionSource adds no new processing methods.
ActionEvent creation occurs when the system detects that the component implementing
ActionSource has been activated. For example, a button has been pressed. This happens
when the decode() processing of the Apply Request Values phase of the request
processing lifecycle detects that the corresponding user interface control was activated.
Event listeners that have registered an interest in ActionEvents fired by this component
(see below) are notified at the end of the Apply Request Values or Invoke Application phase,
depending upon the immediate property of the originating UICommand.
3.2.2 ActionSource2
The ActionSource2 interface extends ActionSource and provides a JavaBeans
property analogous to the action property on ActionSource. This allows the
ActionSource concept to leverage the new Unified EL API.
3.2.2.2 Methods
ActionSource2 adds no new processing methods.
3.2.2.3 Events
ActionSource2 adds no new events.
3.2.3 NamingContainer
NamingContainer is a marker interface. Components that implement
NamingContainer have the property that, for all of their children that have non-null
component identifiers, all of those identifiers are unique. This property is enforced by the
renderView() method on ViewHandler. In JSP based applications, it is also enforced
by the UIComponentELTag. Since this is just a marker interface, there are no properties,
methods, or events. Among the standard components, UIForm and UIData implement
NamingContainer. See Section 4.1.4 “UIForm” and Section 4.1.3.3 “UIData” for details
of how the NamingContainer concept is used in these two cases.
3.2.4 StateHolder
The StateHolder interface is implemented by UIComponent, Converter,
FacesListener, and Validator classes that need to save their state between requests.
UIComponent implements this interface to denote that components have state that must be
saved and restored between requests.
3.2.4.1 Properties
The following render-independent properties are added by the StateHolder interface:
3.2.4.2 Methods
Any class implementing StateHolder must implement both the saveState() and
restoreState() methods, since these two methods have a tightly coupled contract
between themselves. In other words, if there is an inheritance hierarchy, it is not permissible
to have the saveState() and restoreState() methods reside at different levels of the
hierarchy.
If the state saving method is server, these methods may not be called.
If the class that implements this interface has references to Objects which do not implement
StateHolder, these methods must ensure that the references are preserved. For example,
consider class MySpecialComponent, which implements StateHolder, and keeps a
reference to a helper class, MySpecialComponentHelper, which does not implement
StateHolder. MySpecialComponent.saveState() must save enough information
about MySpecialComponentHelper, so that when
MySpecialComponent.restoreState() is called, the reference to
MySpecialComponentHelper can be restored. The return from saveState() must be
Serializable.
Since all of the standard user interface components listed in Chapter 4 “Standard User
Interface Components” extend from UIComponent, they all implement the StateHolder
interface. In addition, the standard Converter and Validator classes that require state to
be saved and restored also implement StateHolder.
3.2.4.3 Events
StateHolder does not originate any standard events.
3.2.5 ValueHolder
ValueHolder is an interface that may be implemented by any concrete UIComponent
that wishes to support a local value, as well as access data in the model tier via a value
expression, and support conversion between String and the model tier data's native
data type.
converter RW Converter The Converter (if any) that is registered for this
UIComponent.
value RW Object First consult the local value property of this
component. If non-null return it. If the local value
property is null, see if we have a
ValueExpression for the value property. If so,
return the result of evaluating the property,
otherwise return null.
localValue RO Object allows any value set by calling setValue() to be
returned, without potentially evaluating a
ValueExpression the way that getValue()
will do
Like nearly all component properties, the value property may have a value binding
expression (see Section 3.1.4 “ValueExpression properties”) associated with it. If present
(and if there is no value set directly on this component), such an expression is utilized to
retrieve a value dynamically from a model tier object during Render Response Phase of the
request processing lifecycle. In addition, for input components, the value expression is used
during Update Model Values phase (on the subsequent request) to push the possibly updated
component value back to the model tier object.
The Converter property is used to allow the component to know how to convert the model
type from the String format provided by the Servlet API to the proper type in the model
tier.
3.2.5.2 Methods
ValueHolder adds no methods.
3.2.5.3 Events
ValueHolder does not originate any standard events.
3.2.6.1 Properties
The following render-independent properties are added by the EditableValueHolder
interface:
3.2.6.2 Methods
The following methods support the validation functionality performed during the Process
Validations phase of the request processing lifecycle:
If the validator property is not null, the method it points at must be called by the
processValidations() method, after the validate() method of all registered
Validators is called.
The addValidator ’s Validator argument must be inspected for the presense of the
ResourceDependency and ResourceDependencies annotations as described in the
Javadocs for the addValidator method.
3.2.7 SystemEventListenerHolder
Classes that implement this interface agree to maintain a list of SystemEventListener
instances for each kind of SystemEvent they can generate. This interface enables arbitrary
Objects to act as the source for SystemEvent instances.
3.2.7.1 Properties
This interface contains no JavaBeans properties
3.2.7.2 Methods
The following method gives the JSF runtime access to the list of listeners stored by this
instance.:
public List<FacesLifecycleListener>
getListenersForEventClass(Class<? extends SystemEvent>
facesEventClass);
3.2.7.3 Events
While the class that implements SystemEventListenerHolder is indeed a source of
events, it is a call to Application.publishEvent() that causes the event to actually
be emitted. In the interest of maximum flexibility, this interface does not define how listeners
are added, removed, or stored. See Section 3.4 “Event and Listener Model” for more details
on the event and listener model provided by JSF.
3.3.1 Overview
A typical web application must constantly deal with two fundamentally different viewpoints
of the underlying data being manipulated through the user interface:
■ The model view—Data is typically represented as Java programming language objects
(often JavaBeans components), with data represented in some native Java programming
language datatype. For example, date and time values might be represented in the model
view as instances of java.util.Date.
■ The presentation view—Data is typically represented in some form that can be perceived
or modified by the user of the application. For example, a date or type value might be
represented as a text string, as three text strings (one each for month/date/year or one each
for hour/minute/second), as a calendar control, associated with a spin control that lets you
increment or decrement individual elements of the date or time with a single mouse click,
or in a variety of other ways. Some presentation views may depend on the preferred
language or locale of the user (such as the commonly used mm/dd/yy and dd/mm/yy date
formats, or the variety of punctuation characters in monetary amount presentations for
various currencies).
To transform data formats between these views, JavaServer Faces provides an ability to plug-
in an optional Converter for each ValueHolder, which has the responsibility of
converting the internal data representation between the two views. The application developer
attaches a particular Converter to a particular ValueHolder by calling
setConverter, passing an instance of the particular converter. A Converter
implementation may be acquired from the Application instance (see Section 7.1.11
“Object Factories”) for your application.
3.3.2 Converter
JSF provides the javax.faces.convert.Converter interface to define the behavioral
characteristics of a Converter. Instances of implementations of this interface are either
identified by a converter identifier, or by a class for which the Converter class asserts that
it can perform successful conversions, which can be registered with, and later retrieved from,
an Application, as described in Section 7.1.11 “Object Factories”.
For UIInput and UIOutput components that wish to explicitly select a Converter to be
used, a new Converter instance of the appropriate type must be created, optionally
configured, and registered on the component by calling setConverter()1. Otherwise, the
JSF implementation will automatically create new instances based on the data type being
converted, if such Converter classes have been registered. In either case, Converter
implementations need not be threadsafe, because they will be used only in the context of a
single request processing thread.
The following two method signatures are defined by the Converter interface:
This method is used to convert the presentation view of a component’s value (typically a
String that was received as a request parameter) into the corresponding model view. It is
called during the Apply Request Values phase of the request processing lifecycle.
This method is used to convert the model view of a component’s value (typically some native
Java programming language class) into the presentation view (typically a String that will be
rendered in some markup language. It is called during the Render Response phase of the
request processing lifecycle.
1. In a JSP environment, these steps are performed by a custom tag extending ConverterTag.
[P1-start standard converters] The following converter id values must be registered to create
instances of the specified Converter implementation classes:
■ javax.faces.BigDecimal -- An instance of
javax.faces.convert.BigDecimalConverter (or a subclass of this class).
■ javax.faces.BigInteger -- An instance of
javax.faces.convert.BigIntegerConverter (or a subclass of this class).
■ javax.faces.Boolean -- An instance of
javax.faces.convert.BooleanConverter (or a subclass of this class).
■ javax.faces.Byte -- An instance of javax.faces.convert.ByteConverter
(or a subclass of this class).
■ javax.faces.Character -- An instance of
javax.faces.convert.CharacterConverter (or a subclass of this class).
■ javax.faces.DateTime -- An instance of
javax.faces.convert.DateTimeConverter (or a subclass of this class).
■ javax.faces.Double -- An instance of
javax.faces.convert.DoubleConverter (or a subclass of this class).
■ javax.faces.Float -- An instance of
javax.faces.convert.FloatConverter (or a subclass of this class).
■ javax.faces.Integer -- An instance of
javax.faces.convert.IntegerConverter (or a subclass of this class).
■ javax.faces.Long -- An instance of javax.faces.convert.LongConverter
(or a subclass of this class).
■ javax.faces.Number -- An instance of
javax.faces.convert.NumberConverter (or a subclass of this class).
■ javax.faces.Short -- An instance of
javax.faces.convert.ShortConverter (or a subclass of this class).
[P1-start by-Class converters] A JSF implementation must register converters for all of the
following classes using the by-type registration mechanism:
■ java.math.BigDecimal, and java.math.BigDecimal.TYPE -- An instance
of javax.faces.convert.BigDecimalConverter (or a subclass of this class).
■ java.math.BigInteger, and java.math.BigInteger.TYPE -- An instance
of javax.faces.convert.BigIntegerConverter (or a subclass of this class).
■ java.lang.Boolean, and java.lang.Boolean.TYPE -- An instance of
javax.faces.convert.BooleanConverter (or a subclass of this class).
■ java.lang.Byte, and java.lang.Byte.TYPE -- An instance of
javax.faces.convert.ByteConverter (or a subclass of this class).
■ java.lang.Character, and java.lang.Character.TYPE -- An instance of
javax.faces.convert.CharacterConverter (or a subclass of this class).
■ java.lang.Double, and java.lang.Double.TYPE -- An instance of
javax.faces.convert.DoubleConverter (or a subclass of this class).
■ java.lang.Float, and java.lang.Float.TYPE -- An instance of
javax.faces.convert.FloatConverter (or a subclass of this class).
■ java.lang.Integer, and java.lang.Integer.TYPE -- An instance of
javax.faces.convert.IntegerConverter (or a subclass of this class).
■ java.lang.Long, and java.lang.Long.TYPE -- An instance of
javax.faces.convert.LongConverter (or a subclass of this class).
■ java.lang.Short, and java.lang.Short.TYPE -- An instance of
javax.faces.convert.ShortConverter (or a subclass of this class).
■ java.lang.Enum, and java.lang.Enum.TYPE -- An instance of
javax.faces.convert.EnumConverter (or a subclass of this class).
[P1-end] See the Javadocs for these classes for a detailed description of the conversion
operations they perform, and the configuration properties that they support.
[P1-start allowing string converters] A compliant implementation must allow the registration
of a converter for class java.lang.String and java.lang.String.TYPE that will
be used to convert values for these types. [P1-end]
3.4.1 Overview
JSF implements a model for event notification and listener registration based on the design
patterns in the JavaBeans Specification, version 1.0.1. This is similar to the approach taken
in other user interface toolkits, such as the Swing Framework included in the JDK.
A UIComponent subclass may choose to emit events that signify significant state changes,
and broadcast them to listeners that have registered an interest in receiving events of the type
indicated by the event’s implementation class. At the end of several phases of the request
processing lifecycle, the JSF implementation will broadcast all of the events that have been
queued to interested listeners. As of JSF version 2, the specification also defines system
events. System events are events that are not specific to any particular application, but rather
stem from specific points in time of running a JSF application. The following UML class
diagram illustrates the key players in the event model. Boxes shaded in gray indicate classes
or interfaces defined outside of the javax.faces.event package.
In conformance to the naming patterns defined in the JavaBeans Specification, event classes
typically have a class name that ends with Event. It is recommended that application event
classes follow this naming pattern as well.
The component that is the source of a FacesEvent can be retrieved via this method:
FacesEvent has a phaseId property (of type PhaseId, see Section 3.4.2.3 “Phase
Identifiers”) used to identify the request processing lifecycle phase after which the event will
be delivered to interested listeners.
If this property is set to PhaseId.ANY_PHASE (which is the default), the event will be
delivered at the end of the phase in which it was enqueued.
The processListener() method must call the appropriate event processing method on
the specified listener. Typically, this will be implemented by casting the listener to the
corresponding FacesListener subinterface and calling the appropriate event processing
method, passing this event instance as a parameter.
The above convenience method calls the queueEvent() method of the source
UIComponent for this event, passing this event as a parameter.
JSF includes two standard FacesEvent subclasses, which are emitted by the corresponding
standard UIComponent subclasses described in the following chapter.
■ ActionEvent—Emitted by a UICommand component when the user activates the
corresponding user interface control (such as a clicking a button or a hyperlink).
■ ValueChangeEvent—Emitted by a UIInput component (or appropriate subclass)
when a new local value has been created, and has passed all validations.
Corresponding to the two standard event classes described in the previous section, JSF
defines two standard event listener interfaces that may be implemented by application
classes:
■ ActionListener—a listener that is interested in receiving ActionEvent events.
■ ValueChangeListener—a listener that is interested in receiving
ValueChangeEvent events.
The application (or other components) may register listener instances at any time, by calling
the appropriate add method. The set of listeners associated with a component is part of the
state information that JSF saves and restores. Therefore, listener implementation classes must
have a public zero-argument constructor, and may implement StateHolder (see
Section 3.2.4 “StateHolder”) if they have internal state information that needs to be saved
and restored.
The UICommand and UIInput standard component classes include listener registration and
deregistration methods for event listeners associated with the event types that they emit. The
UIInput methods are also inherited by UIInput subclasses, including
UISelectBoolean, UISelectMany, and UISelectOne.
Deferring event broadcast until the end of a request processing lifecycle phase ensures that
the entire component tree has been processed by that state, and that event listeners all see the
same consistent state of the entire tree, no matter when the event was actually queued.
System events that originate from or are associated with specific component instances should
extend from ComponentSystemEvent, which extends SystemEvent and adds a
getComponent() method, as specififed in 3.4.2.1.
See the javadoc for UIComponent for the normative specification of these methods.
3.5.1 Overview
JSF supports a mechanism for registering zero or more validators on each
EditableValueHolder component in the component tree. A validator’s purpose is to
perform checks on the local value of the component, during the Process Validations phase of
the request processing lifecycle. In addition, a component may implement internal checking
in a validate method that is part of the component class.
The application (or other components) may register validator instances at any time, by
calling the addValidator method. The set of validators associated with a component is
part of the state information that JSF saves and restores. Validators that wish to have
configuration properties saved and restored must also implement StateHolder (see
Section 3.2.4 “StateHolder”).
Please see Section 2.5.2.4 “Localized Application Messages” for the list of message
identifiers.
[P1-start standard validators] The following standard Validator implementations (in the
javax.faces.validator package) are provided:
■ DoubleRangeValidator—Checks the local value of a component, which must be of
any numeric type, against specified maximum and/or minimum values. Standard identifier
is “javax.faces.DoubleRange”.
■ LengthValidator—Checks the length (i.e. number of characters) of the local value of
a component, which must be of type String, against maximum and/or minimum values.
Standard identifier is “javax.faces.Length”.
■ LongRangeValidator—Checks the local value of a component, which must be of any
numeric type convertible to long, against maximum and/or minimum values. Standard
identifier is “javax.faces.LongRange”.
PENDING(edburns): relocate this fact: All of the UIComponent instances in the PDL page
are children of a special facet of the top level component. The composite component renderer
knows how to render this facet.
It is easy to write a class that adheres to this definition, but in practice, component authors
need to do more than just this in order to get the most from JSF and to conform to user’s
expectations of what a JSF UI Component is. For example, users expect a JSF UI Component
can do some or all of the following:
■ be exposed to the page-author via a markup tag with sensible attributes
■ emit events (such a ValueChangeEvent or ActionEvent)
■ allow attaching listeners
■ allow attaching a Converter and/or Validator(s)
■ render itself to the user-agent, with full support for styles, localization and accessibility
■ support delegated rendering to allow for client device independence
■ read values sent from the user-agent and correctly adapt them to the faces lifecycle
■ correctly handle saving and restoring its state across multiple requests from the user-agent
3.6.1.2 How does one make a custom JSF User Interface component (JSF
1.2 and earlier)?
To satisfy a user’s expectations for a JSF UI component, the component author must adhere
to one of the following best practices.
■ extend the custom component class from an existing subclass of UIComponent that
most closely represents the meaning and behavior of the piece of the UI you are
encapsulating in the component.
■ extend the custom component class directly from UIComponentBase and implement
the appropriate “behavioral interface”(s) that most closely represents the meaning and
behavior of the piece of the UI you are encapsulating in the component. See Section 3.2
“Component Behavioral Interfaces” for more.
Note that the first best practice includes the second one “for free” since the stock
UIComponent subclasses already implement the appropriate behavioral interfaces.
When following either best practice, the JSF UI component developer must follow several
steps to make the component available for use in markup pages or in code, including but not
necessarily limited to
■ Make entries in a faces-config.xml file, linking the component class to its
component-type, which enables the Application.createComponent()
method to create instances of the component.
■ Make entries in a faces-config.xml file to declare a Renderer that provides client-
device independence.
■ Provide a JSP or Facelet tag handler that allows the page author to build UIs that include
the component, and to customize each instance of the component with listeners, properties
and model associations. This includes making the association between the Renderer and
the UIComponent.
■ Provide a Renderer that provides client device independency for the component
■ Make entries in a faces-config.xml file that links the Renderer and its Java class.
Any valid Facelet markup is valid for use inside of a composite component, including the
templating features specified in Section 10.3.3 “Facelet Templating Tag Library”. In
addition, the tag library specified in Section 10.3.4 “Composite Component Tag Library”
must be used to declare the meta-data for the composite component. Future versions of the
JSF specification may relax this requirement, but for now at least the
<composite:interface> and <composite:implementation> sections are
required when creating a composite component.
<h:body>
<h:form>
<ez:loginPanel id="loginPanel">
<f:actionListener for="loginEvent"
binding="#{bean.loginEventListener}" />
</ez:loginPanel>
</h:form>
</h:body>
</html>
The only thing special about this page is the ez namespace declaration and the inclusion of
the <ez:loginPanel /> tag on the page. The occurrence of the string
“http://java.sun.com/jsf/composite/” in a Facelet XML namespace declaration
means that whatever follows that last “/” is taken to be the name of a resource library. For
any usage of this namespace in the page, such as <ez:loginPanel />, a Facelet markup
file with the corresponding name is loaded and taken to be the composite component, in this
case the file loginPanel.xhtml. The implementation requirements for this and other
Facelet features related to composite components are specified in Section 10.2.2
“Requirements specific to composite components”.
</head>
<body>
<composite:interface>
</composite:interface>
<composite:implementation>
</composite:implementation>
</body>
</html>
The <composite:interface> section declares the public interface that users of this
component need to understand. In this case, the component declares that it contains an
implementation of ActionSource2 (see Section 3.2.2 “ActionSource2”), and therefore
anything one can do with an ActionSource2 in a Facelet markup page you one do with
the composite component. (See Section 3.2 “Component Behavioral Interfaces” for more on
ActionSource2 and other behavioral interfaces). The
<composite:implementation> section defines the implementation of this composite
component.
1. The user-agent requests the index.html from Section 3.6.1.4 “A simple composite
component example”. This page contains the ‘xmlns:ez=
"http://java.sun.com/jsf/composite/ezcomp"‘ declaration and an occurrence
of the <ez:loginPanel> tag. Because this page contains a usage of a composite
component, it is called a using page for discussion.
The runtime notices the use of an xml namespace beginning with
“http://java.sun.com/jsf/composite/”. Takes the substring of the namespace
after the last “/”, exclusive, and looks for a resource library with the name “ezcomp” by
calling ResourceHandler.libraryExists().
2. The runtime encounters the <ez:loginPanel> component in the using page. This
causes Application.createComponent(FacesContext, Resource) to be
called. This method calls
PageDeclarationLanguage.getComponentMetadata(FacesContext,
Resource), which obtains the composite component BeanInfo (and therefore also the
composite component BeanDescriptor) that exposes the composite component metadata.
The composite component metadata also includes any attached object targets exposed by
the composite component author. One thing that
Application.createComponent(FacesContext, Resource) does to the
component before returning it is set the component’s renderer type to be
javax.faces.Composite. This is important during rendering.
Note that Application.createComponent(FacesContext, Resource) does
not populate the top level component with children. Subsequent processing done as the
runtime traverses the rest of the page takes care of that. One very important aspect of that
subsequent processing is ensuring that all of the UIComponent children in the defining
page are placed in a facet underneath the top level component. The name of that facet is
given by the UIComponent.COMPOSITE_FACET_NAME constant.
3. After the children of the composite component tag in the using page have been processed
by the PDL implementation, the PDL implementation must call
PDLUtils.retargetAttachedObjects(). This method examines the composite
component metadata and retargets any attached objects from the using page to their
approriate inner component targets.
Attached Object Target Part of the composite component metadata that allows the composite component author
to expose the semantics of an inner component to the using page author without
exposing the rendering or implementation details of the inner component.
Composite Component A tree of UIComponent instances, rooted at a top level component, that can be
thought of and used as a single component in a view. The component hierarchy of this
subtree is described in the composite component defining page.
Composite Component
Author The individual or role creating the composite component. This usually involves
authoring the composite component defining page.
Composite Component
BeanDescriptor A constituent element of the composite component metadata. This version of the spec
uses the JavaBeans API to expose the component meta-data for the composite
component. Future versions of the spec may use a different API to expose the
component meta-data.
Composite Component
BeanInfo The main element of the composite component metadata.
Composite Component
Declaration The section of markup within the composite component defining page that includes the
<composite:interface> section and its children.
Composite Component
Definition The section of markup within the composite component defining page that includes the
<composite:implementation> section and its children.
Composite Component
Metadata Any data about the composite component. The normative specification for what must
be in the composite component metadata is in the javadocs for
PageDeclarationLanguage.getComponentMetadata().
Composite Component
Renderer A new renderer in the HTML_BASIC render kit that knows how to render a composite
component.
Composite Component
Tag The tag in the using page that references a composite component declared and defined
in a defining page.
Defining page The markup page, usually Facelets markup, that contains the composite component
declaration and composite component definition.
Top level component The UIComponent instance in the tree that is the parent of all UIComponent
instances within the defining page and any pages used by that defining page.
Using Page The PDL page in which a composite component tag is used.
Using Page Author The individual or role that creates pages that use the composite component.
The normative specification for composite component metadate is given in the javadocs for
the method PageDeclarationLanguage.getComponentMetadata().
In addition to the abstract base class UIComponent and the abstract base class
UIComponentBase, described in the previous chapter, JSF provides a number of concrete
user interface component implementation classes that cover the most common requirements.
In addition, component writers will typically create new components by subclassing one of
the standard component classes (or the UIComponentBase class). It is anticipated that the
number of standard component classes will grow in future versions of the JavaServer Faces
specification.
The following UML class diagram shows the classes and interfaces in the package
javax.faces.component.
4.1.1.2 Properties
UIColumn adds the following render-independent properties:
4.1.1.3 Methods
UIColumn adds no new processing methods.
4.1.1.4 Events
UIColumn adds no new event handling methods.
4.1.2.2 Properties
UICommand adds the following render-independent properties.
See Section 3.2.1 “ActionSource” for information about properties introduced by the
implemented classes.
4.1.2.3 Methods
UICommand adds no new processing methods. See Section 3.2.1 “ActionSource” for
information about methods introduced by the implemented classes.
4.1.2.4 Events
UICommand adds no new event processing methods. See Section 3.2.1 “ActionSource” for
information about event handling introduced by the implemented classes.
4.1.3.2 Properties
UIData adds the following render-independent properties.
rows RW int The number of rows (starting with the one identified
by the first property) to be displayed, or zero to
display the entire set of available rows.
value RW Object The DataModel instance representing the data to
which this component is bound, or a collection of
data for which a DataModel instance is
synthesized. See below for more information.
var RW String The request-scope attribute (if any) under which the
data object for the current row will be exposed when
iterating.
See Section 3.2.3 “NamingContainer” for information about properties introduced by the
implemented classes.
The current value identified by the value property is normally of type DataModel. [P1-
start-uidataModel]However, a DataModel wrapper instance must automatically be provided
by the JSF implementation if the current value is of one of the following types:
■ java.util.List
■ Array of java.util.Object
■ java.sql.ResultSet (which therefore also supports javax.sql.RowSet)
■ javax.servlet.jsp.jstl.sql.Result
■ Any other Java object is wrapped by a DataModel instance with a single row.[P1-end]
4.1.3.3 Methods
UIData adds no new processing methods. However, the getDataModel() method is now
protected, so implementations have access to the underlying data model. See Section 3.2.3
“NamingContainer” for information about methods introduced by the implemented classes.
UIData specializes the behavior of the queueEvent() method inherited from its parent,
to wrap the specified event (bubbled up from a child component) in a private wrapper
containing the current rowIndex value, so that this rowIndex can be reset when the event is
later broadcast.
UIData specializes the behavior of the broadcast() method to unwrap the private
wrapper (if this event was wrapped), and call setRowIndex() to re-establish the context
in which the event was queued, followed by delivery of the event.
4.1.3.4 Events
UIData adds no new event handling methods. SeeSection 3.2.3 “NamingContainer” for
information about event handling introduced by the implemented classes.
4.1.4.2 Properties
UIForm adds the following render-independent properties.
4.1.4.3 Methods.
4.1.4.4 Events
UIForm adds no new event handling methods.
4.1.5.2 Properties
The following render-independent properties are added by the UIGraphic component:
4.1.5.3 Methods
UIGraphic adds no new processing methods.
4.1.5.4 Events
UIGraphic does not originate any standard events.
4.1.6.2 Properties
UIInput adds the following renderer independent properties.:
See Section 3.2.6 “EditableValueHolder” for information about properties introduced by the
implemented interfaces.
4.1.6.3 Methods
The following method is used during the Update Model Values phase of the request
processing lifecycle, to push the converted (if necessary) and validated (if necessary) local
value of this component back to the corresponding model bean property.
Perform the algorithm described in the javadoc to validate the local value of this UIInput..
Perform the algorithm described in the javadoc to reset this UIInput to the state where it
has no local value. This method does not touch the value expresson associated with the
“value” property.
4.1.7.2 Properties
The following render-independent properties are added by the UIMessage component:
4.1.7.3 Methods.
UIMessage adds no new processing methods.
4.1.8.2 Properties
The following render-independent properties are added by the UIMessages component:
4.1.8.3 Methods.
UIMessages adds no new processing methods.
4.1.8.4 Events
UIMessages adds no new event handling methods.
4.1.9.2 Properties
UIOutput adds no new render-independent properties. See Section 3.2.5 “ValueHolder” for
information about properties introduced by the implemented classes.
4.1.9.3 Methods
UIOutput adds no new processing methods. See Section 3.2.5 “ValueHolder” for
information about methods introduced by the implemented interfaces.
4.1.9.4 Events
UIOutput does not originate any standard events. See Section 3.2.5 “ValueHolder” for
information about events introduced by the implemented interfaces.
4.1.10.2 Properties
UIPanel adds no new render-independent properties.
4.1.10.3 Methods
UIPanel adds no new processing methods.
4.1.10.4 Events
UIPanel does not originate any standard events
4.1.11.2 Properties
The following render-independent properties are added by the UIParameter component:
4.1.11.3 Methods
UIParameter adds no new processing methods.
4.1.11.4 Events
UIParameter does not originate any standard events
4.1.12.2 Properties
The following render-independent properties are added by the UISelectBoolean
component:
4.1.12.3 Methods
UISelectBoolean adds no new processing methods.
4.1.12.4 Events
UISelectBoolean inherits the ability to send ValueChangeEvent events from its
parent UIInput component.
4.1.13.2 Properties
The following render-independent properties are added by the UISelectItem component:
4.1.13.3 Methods
UISelectItem adds no new processing methods.
4.1.13.4 Events
UISelectItem does not originate any standard events.
4.1.14.2 Properties
The following render-independent properties are added by the UISelectItems
component:
4.1.14.3 Methods
UISelectItems adds no new processing methods.
4.1.15.2 Properties
The following render-independent properties are added by the UISelectMany component:
4.1.15.3 Methods
[P1-start-uselectmany-validate]UISelectMany must provide a specialized
validate() method which ensures that any decoded values are valid options (from the
nested UISelectItem and UISelectItems children).[P1-end]
4.1.16.2 Properties
UISelectOne adds no new render-independent properties.
4.1.16.3 Methods
[P1-start-uiselectone-validate]UISelectOne must provide a specialized
validate() method which ensures that any decoded value is a valid option (from the
nested UISelectItem and UISelectItems children).[P1-end]
4.1.16.4 Events
UISelectOne inherits the ability to send ValueChangeEvent events from its parent
UIInput component.
4.1.17.2 Properties
The following render-independent properties are added by the UIViewRoot component:
For an existing view, the locale property may be modified only from the event handling
portion of Process Validations phase through Invoke Application phase, unless it is modified
by an Apply Request Values event handler for an ActionSource or
EditableValueHolder component that has its immediate property set to true (which
therefore causes Process Validations, Update Model Values, and Invoke Application phases to
be skipped).
4.1.17.3 Methods
The following methods are used for adding UIComponent resources to a target area in the
view, and they are also used for retrieving UIComponent resources from a target area in the
view.
Return a List of UIComponent instances residing under the facet identified by target.
Each UIComponent instance in the List represents a resource. [P1-start-getCompRes]
The List must be formulated in accordance with this method’s Javadocs. [P1-end]
4.1.17.4 Events
UIViewRoot is a source of PhaseEvent events, which are emitted when the instance
moves through all phases of the request processing lifecycle except Restore View. This phase
cannot emit events from UIViewRoot because the UIViewRoot instance isn’t created
when this phase starts. See Section 12.2 “PhaseEvent” and Section 12.3 “PhaseListener”for
more details on the event and listener class.
4.2.1 DataModel
DataModel is an abstract base class for creating wrappers around arbitrary data binding
technologies. It can be used to adapt a wide variety of data sources for use by JavaServer
Faces components that want to support access to an underlying data set that can be modelled
as multiple rows. The data underlying a DataModel instance is modelled as a collection of
row objects that can be accessed randomly via a zero-relative index
4.2.1.1 Properties
An instance of DataModel supports the following properties:
rowAvailable RO boolean Flag indicating whether the current rowIndex value points at an
actual row in the underlying data.
rowCount RO int The number of rows of data objects represented by this DataModel
instance, or -1 if the number of rows is unknown.
rowData RO Object An object representing the data for the currently selected row.
DataModel implementations must return an object that be
successfully processed as the “base” parameter for the
PropertyResolver in use by this application. If the current
rowIndex value is -1, null is returned.
rowIndex RW int Zero-relative index of the currently selected row, or -1 if no row is
currently selected. When first created, a DataModel instance
must return -1 for this property.
wrappedData RW Object Opaque property representing the data object wrapped by this
DataModel. Each individual implementation will restrict the types
of Object(s) that it supports.
4.2.1.3 Events
No events are generated for this component.
Each concrete DataModel implementation must extend the DataModel abstract base
class, and must provide a constructor that accepts a single parameter of the object type being
wrapped by that implementation (in addition to a zero-args constructor).[P1-end] See the
JavaDocs for specific implementation requirements on DataModel defined methods, for
each of the concrete implementation classes.
4.2.2.1 Properties
An instance of SelectItem supports the following properties:
description RW String A description of this selection item, for use in development tools.
disabled RW boolean Flag indicating that this option should be rendered in a fashion that
disables selection by the user. Default value is false.
label RW String Label of this selection item that should be rendered to the user.
value RW Object The server-side value of this item, of the same basic data type as
the parent component’s value. If the parent component type’s value
is a value expression that points at a primitive, this value must be
of the corresponding wrapper type.
4.2.2.2 Methods
An instance of SelectItem supports no additional public processing methods.
4.2.2.3 Events
An instance of SelectItem supports no events.
4.2.3.1 Properties
An instance of SelectItemGroup supports the following additional properties:
4.2.3.2 Methods
An instance of SelectItemGroup supports no additional public processing methods.
4.2.3.3 Events
An instance of SelectItemGroup supports no events.
In the descriptions of the standard user interface component model, it was noted that all
attributes, and nearly all properties can have a value expression associated with them (see
Section 3.1.4 “ValueExpression properties”). In addition, many properties, such as action,
actionListener, validator, and valueChangeListener can be defined by a
method expression pointing at a public method in some class to be executed. This chapter
describes the mechanisms and APIs that JavaServer Faces utilizes in order to evaluate value
expressions and method expressions.
JavaServer Faces relies on the Unified Expression Language (Unified EL, or just EL)
provided by version 2.1 of the JavaServer Pages specification (JSR-245). The EL is
described in a separate specification document delivered as part of the JSP 2.1 spec. Please
consult that document for complete details about the EL.
Versions 1.0 and 1.1 of JavaServer Faces included a built in expression language and
required an implementation of it. The API for this old JSF EL is still preserved as deprecated
classes and methods, and implementations must still support that API. Please consult the
Section 2.1.0.1 “Guide to Deprecated Methods Relating to the Unified EL and their
Corresponding Replacements” for details. This chapter will focus exclusively on how Faces
leverages and integrates with the Unified EL. It does not describe how the Unified EL
operates.
5.1.1 Overview
To support binding of attribute and property of values to dynamically calculated results, the
name of the attribute or property can be associated with a value expression using the
setValueExpression() method. Whenever the dynamically calculated result of
evaluating the expression is required, the getValue() method of the ValueExpression
is called, which returns the evaluated result. Such expressions can be used, for example, to
dynamically calculate a component value to be displayed:
<h:outputText value=”#{customer.name}”/>
which, when this page is rendered, will retrieve the bean stored under the “customer” key,
then acquire the name property from that bean and render it.
Besides the component value itself, value expressions can be used to dynamically compute
attributes and properties. The following example checks a boolean property manager on
the current user bean (presumably representing the logged-in user) to determine whether
the salary property of an employee should be displayed or not:
which sets the rendered property of the component to false if the user is not a manager,
and therefore causes this component to render nothing.
Value expressions can also be used to set a value from the user into the item obtained by
evaluating the expression. For example:
<h:inputText value=”#{employee.number}”/>
When the page is rendered, the expression is evaluated as an r-value and the result is
displayed as the default value in the text field. When the page is submitted, the expression is
evaluated as an l-value, and the value entered by the user (subject to conversion and
validation as usual) is pushed into the expression.
5.2 MethodExpressions
Method expressions are a very similar to value expressions, but rather than supporting the
dynamic retrieval and setting of properties, method expressions support the invocation (i.e.
execution) of an arbitrary public method of an arbitrary object, passing a specified set of
parameters, and returning the result from the called method (if any). They may be used in
any phase of the request processing lifecycle; the standard JSF components and framework
employ them (encapsulated in a MethodExpression object) at the following times:
■ During Apply Request Values or Invoke Application phase (depending upon the state of the
immediate property), components that implement the ActionSource2 behavioral
interface (see Section 3.2.2 “ActionSource2”) utilize MethodExpressions as follows:
■ If the actionExpression property is specified, it must be a MethodExpression
expression that identifies an Application Action method (see Section 7.3 “Application
Actions”) that takes no parameters and returns a String.
■ It’s possible to have a method expression act as an ActionListener by using the
classs MethodExpressionActionListener to wrap a method expression and
calling the addActionListener() method on the ActionSource. The method
expression wrapped inside the MethodExpressionActionListener must
identify a public method that accepts an ActionEvent (see Section 3.4.2.1 “Event
Classes”) instance, and has a return type of void. The called method has exactly the
same responsibilities as the processAction() method of an ActionListener
instance (see Section 3.4.2.2 “Listener Classes”) that was built in to a separate Java
class.
■ During the Apply Request Values or Process Validations phase (depending upon the state
of the immediate property), components that implement EditableValueHolder
(such as UIInput and its subclasses) components (see Section 3.2.6
“EditableValueHolder”) utilize method expressions as follows:
■ The user can use the MethodExpressionValidator class to wrap a method
expression that identifies a public method that accepts a FacesContext instance and
a UIComponent instance, and an Object containing the value to be validated, and
has a return type of void. This MethodExpressionValidator instance can then
be added as a normal Validator using the
EditableValueHolder.addValidator() method. The called method has
exactly the same responsibilities as the validate() method of a Validator
instance (see Section 3.5.2 “Validator Classes”) that was built in to a separate Java
class.
Here is the set of component properties that currently support MethodBinding, and the
method signatures to which they must point:
component listener
property Wrapper class method signature
After the new managed bean instance is instantiated, but before it is placed into the specified
scope (if any), each nested <managed-property> element must be processed and a call
to the corresponding property setter must be made to initialize the value of the corresponding
property. If the managed bean has properties not referenced by <managed-property>
elements, the values of such properties will not be affected by the creation of this managed
bean; they will retain whatever default values are established by the constructor.
As described above, the <map-entries> element is used to initialize the key-value pairs
of a property of type java.util.Map. This element may contain the following nested
elements:
■ <key-class> -- Optional element specifying the fully qualified class name for keys in
the map to be created. If not specified, java.lang.String is used.
■ <value-class> -- Optional element specifying the fully qualified class name for
values in the map to be created. If not specified, java.lang.String is used.
■ <map-entry> -- Zero or more elements that define the actual key-value pairs for a
single entry in the map. Nested inside is a <key> element to define the key, and then
exactly one of <null-value>, <value> to define the value. These elements have the
same meaning as when nested in a <managed-property> element, except that they
refer to an individual map entry’s value instead of the entire property value.
As described above, the <list-entries> element is used to initialize a set of values for
a property of type array or java.util.List. This element may contain the following
nested elements:
■ <value-class> -- Optional element specifying the fully qualified class name for
values in the map to be created. If not specified, java.lang.String is used.
■ Zero or more elements of type <null-value>, <value> to define the individual
values to be initialized. These elements have the same meaning as when nested in a
<managed-property> element, except that they refer to an individual list element
instead of the entire property value.
The following general rules apply to the operation of the Managed Bean Creation facility:
■ Properties are assigned in the order that their <managed-property> elements are
listed in the application configuration resource.
■ If a managed bean has writeable properties that are not mentioned in <managed-
property> elements, the values of those properties are not assigned any values.
■ The bean instantiation and population with properties must be done lazily, when an EL
expression causes the bean to be referenced. For example, this is the case when a
ValueExpression or MethodExpression has its getValue() or setValue()
method called.
■ Due to the above mentioned laziness constraint, any error conditions that occur below are
only required to be manifested at runtime. However, it is conceivable that tools may want
to detect these errors earlier; this is perfectly acceptable. The presense of any of the errors
described below, until the end of this section, must not prevent the application from
deploying and being made available to service requests.
For <map-entries>:
3. Add all entries defined by nested <map-entry> elements in the order they are listed,
converting key values defined by nested <key> elements to the type defined by <key-
class> and entry values defined by nested <value> elements to the type defined by
<value-class>. If a value is given as a value expression, evaluate the reference and
store the result, converting to <value-class> if necessary. If <key-class> and/or
<value-class> are not defined, use java.lang.String. Add null for each
<null-value> element.
4. If a new java.util.Map was created in step 2), set the property by calling the setter
method, or log an error if there is no setter method.
For <list-entries>:
3. If a List was returned or created in step 2), add all elements defined by nested
<value> elements in the order they are listed, converting values defined by nested
<value> elements to the type defined by <value-class>. If a value is given as a
value expression, evaluate the reference and store the result, converting to <value-
class> if necessary. If a <value-class> is not defined, use the value as-is (i.e., as a
java.lang.String). Add null for each <null-value> element.
5. If a new java.util.List was created in step 2) and the property is of type List, set
the property by calling the setter method, or log an error if there is no setter method.
6. If a new java.util.List was created in step 2) and the property is a java array,
convert the List into an array of the property type, and set it by calling the setter
method, or log an error if there is no setter method.
7. If a new java.util.List was created in step 4), convert the List to an array of the
proper type for the property and set the property by calling the setter method, or log an
error if there is no setter method.
<managed-bean>
<description>
A customer bean will be created as needed, and stored in
request scope. Its “mailingAddress” and “streetAddress”
properties will be initialized by virtue of the fact that the
“value” expressions will not encounter any object under
key “addressBean” in any scope.
</description>
<managed-bean-name>customer</managed-bean-name>
<managed-bean-class>
com.mycompany.mybeans.CustomerBean
</managed-bean-class>
<managed-bean-scope> request </managed-bean-scope>
<managed-property>
<property-name>mailingAddress</property-name>
<value>#{addressBean}</value>
</managed-property>
<managed-property>
<property-name>shippingAddress</property-name>
<value>#{addressBean}</value>
</managed-property>
<managed-property>
<property-name>customerType</property-name>
<value>New</value> <!-- Set to literal value -->
</managed-property>
</managed-bean>
Although not used by the JSF implementation at application runtime, it is also convenient to
be able to indicate to JSF tools (at design time) that objects of particular types will be created
and made available (at runtime) by some other means. For example, an application
configuration resource could include the following information to declare that a JDBC data
source instance will have been created, and stored in application scope, as part of the
application’s own startup processing.
<referenced-bean>
<description>
A JDBC data source will be initialized and made available in
some scope (presumably application) for use by the JSF based
application when it is actually run. This information is not
used by the JSF implementation itself; only by tools.
</description>
<referenced-bean-name> dataSource </referenced-bean-name>
<referenced-bean-class>
javax.sql.DataSource
</referenced-bean-class>
</referenced-bean>
This information can be utilized by the tool to construct user interfaces based on the
properties of the referenced beans.
Please consult the Java 2 Platform Entprise Edition Specification 5.0 for complete details of
this feature. Here is a summary of the valid injection annotations one may use in a managed
bean. [P1-start valid annotations in a managed bean]
@Resource
@Resources
@EJB
@EJBs
@WebServiceRef
@WebServiceRefs
@PersistenceContext
@PersistenceContexts
@PersistenceUnit
@PersistenceUnits [P1-end]
@Resource(name=”customerData”)
private void setCustomerData(DataSource data) {
customerData = data;
}
This example illustrates that the above annotations can be attached to instance variables or to
JavaBeans setters. The JSF implementation running in a Java EE 5 container must guarantee
that the injections are performed before the bean is handed back to the user. Generally, this is
done by performing the injection immediately after the lazy instantiation of the managed
bean.
Refer to the Java EE specification section 2.5 and the Common Annotations for the JavaTM
PlatformTM specification section 2.5 for more details.[P1-end]
5.5.1 ELContext
The ELContext is a handy little “holder” object that gets passed all around the Unified EL
API. It has two purposes.
■ To allow technologies that use the Unified EL, such as JavaServer Faces, the JSF Page
Declaration Language (JSF PDL), and JSP, to store any context information specific to
that technology so it can be leveraged during expression evaluation. For example the
expression “${view.viewId}” is specific to Faces. It means, “find the UIViewRoot
instance for the current view, and return its viewId”. The Unified EL doesn’t know
about the “view” implicit object or what a UIViewRoot is, but JavaServer Faces does. The
Unified EL has plugin points that will get called to resolve “view”, but to do so,
JavaServer Faces needs access to the FacesContext from within the callstack of EL
evaluation. Therefore, the ELContext comes to the rescue, having been populated with
the FacesContext earlier in the request processing lifecycle.
■ To allow the pluggable resolver to tell the Unified EL that it did, in fact, resolve a
property and that further resolvers must not be consulted. This is done by setting the
“propertyResolved” property to true.
The complete specification for ELResolver may be found in Chapter 2 of the Expression
Language Specification, Version 2.1.
5.5.1.3 Methods
Here is a subset of the methods that are relevant to Faces.
5.5.1.4 Events
The creation of an ELContext instance precipitates the emission of an ELContextEvent
from the FacesContext that created it. Please see Section 6.1.3 “ELContext” for details.
5.5.2 ELResolver
Faces 1.1 used the VariableResolver and PropertyResolver classes as the
workhorses of expression evaluation. The Unified API has the ELResolver instead. The
ELResolver concept is the heart of the Unified EL. When an expression is evaluated, the
ELResolver is responsible for resolving each segment in the expression. For example, in
rendering the component behind the tag “<h:outputText value=
”#{user.address.street}” />” the ELResolver is called three times. Once to resolve
[N/T-start two ELResolver impls] As described in more detail in Section 5.6.1 “Faces
ELResolver for Markup Pages”, Faces must provide two implementations of ELResolver.
[P1-end]Which of these two implementations is actually used to resolve an expression
depends on where the expresison is evaluated. If the expression is evaluated in a markup
page, the ELResolver for markup pages is used. If the expression is evaluated in java VM
hosted code from Faces, another ELResolver is used that is tailored for use inside of Faces
java VM hosted code. During the course of evaluation of an expression, a variety of sources
must be considered to help resolve each segment of the expression. These sources are linked
in a chain-like fashion. Each link in the chain has the opportunity to resolve the current
segment. If it does so, it must set the “propertyResolved” property on the ELContext,
to true. If not, it must not modify the value of the “propertyResolved” property. If the
“propertyResolved” property is not set to true the return value from the
ELResolver method is ignored by the system.
5.5.2.2 Properties
ELResolver has no proper JavaBeans properties
5.5.2.3 Methods
Here is a subset of the methods that are relevant to Faces.
setValue() looks at the argument base and tries to set the argument value into the
property named by the argument property. For example, if base is a JavaBean, property
would be the name of the JavaBeans property, and the resolver would end up calling the
setter for that property.
There are other methods, such as isReadOnly() that are beyond the scope of this
document, but described completely in the Unified EL Specification.
5.5.2.4 Events
ELResolver precipitates no events.
5.5.3 ExpressionFactory
Faces 1.1 used the Application class as a factory for ValueBinding and
MethodBinding instances. The Unified EL has the ExpressionFactory class instead.
It is a factory for ValueExpression and MethodExpression instances.
5.5.3.2 Properties
ExpressionFactory has no properties.
5.5.3.4 Events
ExpressionFactory precipitates no events.
Section 5.5.2 “ELResolver” mentions that a Faces implementation must provide two
implementations of ELResolver. One ELResolver, let’s call it the Faces ELResolver For
Markup Pages, is plugged in to the top level resolver chain returned from
JspContext.getELContext().getELResolver(). This top level resolver chain is
used by the page description language container (JSP or JSF Page Declaration Language),
and possibly by tag handlers, to resolve expressions. The other ELResolver, let’s call it the
ELResolver for Programmatic Access, is not used by markup pages, but rather, is returned
from FacesContext.getELContext().getELResolver() and
Application.getELResolver() and is used to resolve expressions that appear
programmatically. See the javadocs for javax.el.ELResolver for the specification and
method semantics for each method in ELResolver. The remainder of this section lists the
implementation requirements for these two resolvers.
This diagram shows the set of ELResolver instances that must be added to the Faces
ELResolver for Markup Pages. This instance must be handed to the JSP container via a call
to
JspFactory.getDefaultFactory().getJspApplicationContext().addELR
esolver() at application startup time. Even though we are making a JSP API call to install
this ELResolver, we do not require using JSP to develop JSF applications. It also shows
the order in which they must be added. [P2-start there are 18 methods in the below tables,
each can corresponding to a method on a particular ELResolver. With clever testing, it is
possible to write assertions for these. Testing the legacy VariableResolver and
PropertyResolvers is not included in this 18 methods number. These classes may be tested
simply by noting that the methods do indeed get called on a user-provided VariableResolver
or PropertyResolver.] [P1-end]
TABLE 5-3 Faces ELResolver for Markup Pages
The semantics of the ELResolver that functions as the VariableResolver chain wrapper are
described in the following table.
TABLE 5-7 ELResolver that is the VariableResolver Chain Wrapper
The semantics of the ELResolver that functions as the property resolver chain wrapper are
described in the following table.
The implementation for the ELResolver for Programmatic Access is described as a set of
ELResolvers inside of a CompositeELResolver instance, but any implementation
strategy is permissible as long as the semantics are preserved. .
5.7.1 ELResolver
This class is the Unified EL’s answer to Faces’s VariableResolver and
PropertyResolver. It turns out that variable resolution can be seen as a special case of
property resolution with the base object being null. Please see Section 5.5.2 “ELResolver”
for more details.
5.7.2 ValueExpression
This class is the Unified EL’s answer to Faces’s ValueBinding. It is the main object
oriented abstraction for al EL expression that results in a value either being retrieved or set.
Please see Chapter 2 of the Expression Language Specification, Version 2.1.
5.8.3 ValueBinding
The ValueBinding class encapsulates the actual evaluation of a value binding. Instances
of ValueBinding for specific references are acquired from the Application instance
by calling the createValueBinding method (see Section 7.9.3 “Acquiring ValueBinding
Instances”).
Evaluate the value binding used to create this ValueBinding instance, relative to the
specified FacesContext, and update the referenced value to the specified new value.
Evaluate the value binding used to create this ValueBinding instance, relative to the
specified FacesContext, and return true if the corresponding property is known to be
immutable. Otherwise, return false.
Evaluate the value binding used to create this ValueBinding instance, relative to the
specified FacesContext, and return the Class that represents the data type of the
referenced value, if it can be determined. Otherwise, return null.
5.8.4 MethodBinding
The MethodBinding class encapsulates the actual evaluation of a method binding.
Instances of MethodBinding for specific references are acquired from the Application
instance by calling the createMethodBinding() method. Note that instances of
MethodBinding are immutable, and contain no references to a FacesContext (which is
passed in as a parameter when the reference binding is evaluated).
Evaluate the method binding (see Section 5.2.1 “MethodExpression Syntax and Semantics”)
and return the Class representing the return type of the identified method. If this method is
of type void, return null instead.
During request processing for a JSF page, a context object is used to represent request-
specific information, as well as provide access to services for the application. This chapter
describes the classes which encapsulate this contextual information.
6.1 FacesContext
JSF defines the javax.faces.context.FacesContext abstract base class for
representing all of the contextual information associated with processing an incoming
request, and creating the corresponding response. A FacesContext instance is created by
the JSF implementation, prior to beginning the request processing lifecycle, by a call to the
getFacesContext method of FacesContextFactory, as described in Section 6.5
“FacesContextFactory”. When the request processing lifecycle has been completed, the JSF
implementation will call the release method, which gives JSF implementations the
opportunity to release any acquired resources, as well as to pool and recycle
FacesContext instances rather than creating new ones for each request.
6.1.1 Application
public Application getApplication();
6.1.3 ELContext
public ELContext getELContext();
Return the ELContext instance for this FacesContext instance. This ELContext
instance has the same lifetime and scope as the FacesContext instance with which it is
associated, and may be created lazily the first time this method is called for a given
FacesContext instance. [P1-start-elcontext]Upon creation of the ELContext instance, the
implementation must take the following action:
■ Call the ELContext.putContext(java.lang.Class, java.lang.Object)
method on the instance, passing in FacesContext.class and the this reference for
the FacesContext instance itself.
■ If the Collection returned by
javax.faces.Application.getELContextListeners() is non-empty, create
an instance of ELContextEvent and pass it to each ELContextListener instance
in the Collection by calling the
ELContextListener.contextCreated(javax.el.ELContextEvent)
method.[P1-end]
6.1.4 ExternalContext
It is sometimes necessary to interact with APIs provided by the containing environment in
which the JavaServer Faces application is running. In most cases this is the servlet API, but
it is also possible for a JavaServer Faces application to run inside of a portlet. JavaServer
[P1-start externalContext during Init] The default implementation must return a valid value
when this method is called during startup time. See the javadocs for this method for the
complete specification. [P1-end]
During the Restore View phase of the request processing lifecycle, the state management
subsystem of the JSF implementation will identify the component tree (if any) to be used
during the inbound processing phases of the lifecycle, and call setViewRoot() to
establish it.
During the Apply Request Values, Process Validations, Update Model Values, and Invoke
Application phases of the request processing lifecycle, messages can be queued to either the
component tree as a whole (if clientId is null), or related to a specific component based
on its client identifier.
6.1.7 RenderKit
public RenderKit getRenderKit();
Return the RenderKit associated with the render kit identifier in the current UIViewRoot
(if any).
JSF supports output that is generated as either a byte stream or a character stream.
UIComponents or Renderers that wish to create output in a binary format should call
getResponseStream() to acquire a stream capable of binary output. Correspondingly,
UIComponents or Renderers that wish to create output in a character format should call
getResponseWriter() to acquire a writer capable of character output.
Due to restrictions of the underlying servlet APIs, either binary or character output can be
utilized for a particular response—they may not be mixed.
Normally, the phases of the request processing lifecycle are executed sequentially, as
described in Chapter 2 “Request Processing Lifecycle.” However, it is possible for
components, event listeners, and validators to affect this flow by calling one of these
methods.
The renderResponse() method signals the JSF implementation that, at the end of the
current phase (in other words, after all of the processing and event handling normally
performed for this phase is completed), control should be transferred immediately to the
Render Response phase, bypassing any intervening phases that have not yet been performed.
For example, an event listener for a tree control that was designed to process user interface
state changes (such as expanding or contracting a node) on the server would typically call
this method to cause the current page to be redisplayed, rather than being processed by the
application.
The responseComplete() method, on the other hand, signals the JSF implementation
that the HTTP response for this request has been completed by some means other than
rendering the component tree, and that the request processing lifecycle for this request should
be terminated when the current phase is complete. For example, an event listener that
decided an HTTP redirect was required would perform the appropriate actions on the
response object (i.e. calling ExternalContext.redirect()) and then call this method.
public void
setExecutePhaseClientIds(List<String>executePhaseClientIds);
public void
setRenderPhaseClientIds(List<String>renderPhaseClientIds);
Under most circumstances, JSF components, and application objects that access them, are
passed a reference to the FacesContext instance for the current request. However, in
some cases, no such reference is available. The getCurrentInstance() method may be
called by any Java class in the current web application to retrieve an instance of the
FacesContext for this request. [P1-start-currentInstance]The JSF implementation must
ensure that this value is set correctly before FacesContextFactory returns a
FacesContext instance, and that the value is maintained in a thread-safe manner.[P1-end]
6.2 FacesMessage
Each message queued within a FacesContext is an instance of the
javax.faces.application.FacesMessage class. It offers the following
constructors:
public FacesMessage();
The following method signatures are supported to retrieve and set the properties of the
completed message:
6.3 ResponseStream
ResponseStream is an abstract class representing a binary output stream for the current
response. It has exactly the same method signatures as the java.io.OutputStream
class.
6.4 ResponseWriter
ResponseWriter is an abstract class representing a character output stream for the current
response. A ResponseWriter instance is obtained via a factory method on
RenderKit. Please see Chapter 8 “RenderKit”. It supports both low-level and high level
APIs for writing character based information
public void write(char c[], int off, int len) throws IOException;
Return the content type or character encoding used to create this ResponseWriter.
Write the beginning of a markup element (the < character followed by the element name),
which causes the ResponseWriter implementation to note internally that the element is
open. This can be followed by zero or more calls to writeAttribute or
writeURIAttribute to append an attribute name and value to the currently open
element. The element will be closed (i.e. the trailing > added) on any subsequent call to
startElement(), writeComment(), writeText(), endDocument(), close(),
flush(), or write(). The componentForElement parameter tells the
ResponseWriter which UIComponent this element corresponds to, if any. This
parameter may be null to indicate that the element has no corresponding component. The
presence of this parameter allows tools to provide their own implementation of
ResponseWriter to allow the design time environment to know which component
corresponds to which piece of markup.
Write a closing for the specified element, closing any currently opened element first if
necessary.
These methods add an attribute name/value pair to an element that was opened with a
previous call to startElement(), throwing an exception if there is no currently open
element. The writeAttribute() method causes character encoding to be performed in
the same manner as that performed by the writeText() methods. The
writeURIAttribute() method assumes that the attribute value is a URI, and performs
URI encoding (such as % encoding for HTML). The componentPropertyName, if
present, denotes the property on the associated UIComponent for this element, to which
this attribute corresponds. The componentPropertyName parameter may be null to
indicate that this attribute has no corresponding property.
Write text (converting from Object to String first, if necessary), performing appropriate
character encoding and escaping. Any currently open element created by a call to
startElement is closed first.
6.5 FacesContextFactory
[P1-start-facesContextFactory]A single instance of
javax.faces.context.FacesContextFactory must be made available to each
JSF-based web application running in a servlet or portlet container.[P1-end] This class is
FacesContextFactory factory =
(FacesContextFactory)
FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
Create (if necessary) and return a FacesContext instance that has been configured based
on the specified parameters. In a servlet environment, the first argument is a
ServletContext, the second a ServletRequest and the third a ServletResponse.
Application Integration
Previous chapters of this specification have described the component model, request state
information, and the next chapter describes the rendering model for JavaServer Faces user
interface components. This chapter describes APIs that are used to link an application’s
business logic objects, as well as convenient pluggable mechanisms to manage the execution
of an application that is based on JavaServer Faces. These classes are in the
javax.faces.application package.
7.1 Application
There must be a single instance of Application per web application that is utilizing
JavaServer Faces. It can be acquired by calling the getApplication() method on the
FacesContext instance for the current request, or the getApplication() method of
the ApplicationFactory (see Section 7.2 “ApplicationFactory”), and provides default
implementations of features that determine how application logic interacts with the JSF
implementation. Advanced applications (or application frameworks) can install replacements
for these default implementations, which will be used from that point on. Access to several
integration objects is available via JavaBeans property getters and setters, as described in the
following subsections.
An application may specify the render kit identifier of the RenderKit to be used by the
ViewHandler to render views for this application. If not specified, the default render kit
identifier specified by RenderKitFactory.HTML_BASIC_RENDER_KIT will be used
by the default ViewHandler implementation.
Return or replace the StateManager instance that will be utilized during the Restore View
and Render Response phases of the request processing lifecycle to manage state persistence
for the components belonging to the current view. A default implementation must be
provided, which operates as described in Section 7.6 “StateManager”.
[N/T-start elresolver test] Return the ELResolver instance to be used for all EL resolution.
This is actually an instance of javax.el.CompositeELResolver that must contain the
ELResolver instances as specified in Section 5.6.2 “ELResolver for Programmatic
Access”. [N/T-end]
See Section 7.5 “ViewHandler” for the description of the ViewHandler. The JSF
implementation must provide a default ViewHandler implementation. This implementation
may be replaced by calling setViewHandler() before the first time the Render Response
phase has executed. [P1-start setViewHandler() called after startup] If a call is made to
setViewHandler() after the first time the Render Response phase has executed, the call
must be ignored by the implementation. [P1-end]
[P1-start getProjectStage]This method must return the enum constant from the class
javax.faces.application.ProjectStage as specified in the corresponding application
init parameter, JNDI entry, or default Value. See Section 11.1.3 “Application Configuration
Parameters”.[P1-end]
Return the ExpressionFactory instance for this application. This instance is used by the
evaluateExpressionGet (Section 7.1.10 “Programmatically Evaluating
Expressions”) convenience method.
Each of these methods creates a new instance of an object of the requested type1, based on
the requested identifier. The names of the implementation class used for each identifier is
normally provided by the JSF implementation automatically (for standard classes described
in this Specification), or in one or more application configuration resources (see Section 11.4
“Application Configuration Resources”) included with a JSF web application, or embedded
in a JAR file containing the corresponding implementation classes.
All variants createConverter() must take some action to inspect the converter for
@ResourceDependency and @ListenerFor annotations.
1. Converters can also be requested based on the object class of the value to be converted.
All variants createComponent() must take some action to inspect the component for
@ResourceDependency and @ListenerFor annotations. Please see the JavaDocs and
Section 3.6.2 “Composite Component Metadata” for the normative specification relating to
this method.
JSF-based applications can ask the Application instance for a list of the registered
identifiers for components, converters, and validators that are known to the instance.
JSF applications may state the Locales they support (and the default Locale within the set
of supported Locales) in the application configuration resources file. The setters for the
following methods must be called when the configuration resources are parsed. Each time the
setter is called, the previous value is overwritten.
Specify the fully qualified name of the ResourceBundle from which the JSF implementation
will acquire message strings that correspond to standard message keys See Section 2.5.2.4
“Localized Application Messages” for a list of the standard message keys recognized by JSF.
The second variant of subscribeToEvent() is equivalent to the first, with the additional
constraint the the sourceClass argument to publishEvent() must be equal to the
Class object obtained by calling getClass() on the source argument to
publishEvent().
See the javadocs for both variants of subscribeForEvent() for the complete
specification of these methods.
publishEvent() is called by the system at several points in time during the runtime of a
JSF application. The specification for when publishEvent() is called is given in the
javadoc for the event classes that are listed in Section 3.4.2.1 “Event Classes”. See the
javadoc for publishEvent() for the complete specification.
See the javadocs for both variants of unsubscribeFromEvent() for the complete
specification.
7.2 ApplicationFactory
A single instance of javax.faces.application.ApplicationFactory must be
made available to each JSF-based web application running in a servlet or portlet container.
The factory instance can be acquired by JSF implementations or by application code, by
executing:
Return or replace the Application instance for the current web application. The JSF
implementation must provide a default Application instance whose behavior is described
in Section 7.1 “Application”.
Note that applications will generally find it more convenient to access the Application
instance for this application by calling the getApplication() method on the
FacesContext instance for the current request.
Application action is not a formal JSF API; instead any method that meets the following
requirements may be used as an Action by virtue of evaluating a method binding expression:
■ The method must be public.
■ The method must take no parameters.
■ The method must return Object.
7.4 NavigationHandler
7.4.1 Overview
A single NavigationHandler instance is responsible for consuming the logical outcome
returned by an application action that was invoked, along with additional state information
that is available from the FacesContext instance for the current request, and (optionally)
selecting a new view to be rendered. As mentioned below, if the outcome returned by the
application action is null, the same view must be re-displayed. This is the only case where
the same view (and component tree) is re-used..
After a return from the NavigationHandler, control will normally proceed to the Render
Response phase of the request processing lifecycle (see Section 2.2.6 “Render Response”),
which will cause the newly selected view to be rendered. If the NavigationHandler
called the responseComplete() method on the FacesContext instance, however, the
Render Response phase will be bypassed.
2. It is an error to specify more than one <navigation-case>, nested within one or more <navigation-rule> elements with the
same <from-view-id> matching pattern, that have exactly the same combination of <from-xxx> element values.
A rule match always causes a new view to be created, losing the state of the old view.[P1-
end]
<navigation-rule>
<description>
APPLICATION WIDE NAVIGATION HANDLING
</description>
<from-view-id> * </from-view-id>
<navigation-case>
<description>
Assume there is a “Logout” button on every page that
invokes the logout Action.
</description>
<display-name>Generic Logout Button</display-name>
<from-action>#{userBean.logout}</from-action>
<to-view-id>/logout.jsp</to-view-id>
</navigation-case>
<navigation-case>
<description>
Handle a generic error outcome that might be returned
by any application Action.
</description>
<display-name>Generic Error Outcome</display-name>
<from-outcome>loginRequired</from-outcome>
<to-view-id>/must-login-first.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<description>
LOGIN PAGE NAVIGATION HANDLING
</description>
<from-view-id> /login.jsp </from-view-id>
<navigation-case>
<description>
Handle case where login succeeded.
</description>
<display-name>Successful Login</display-name>
<from-action>#{userBean.login}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>/home.jsp</to-view-id>
</navigation-case>
<navigation-case>
<description>
User registration for a new user succeeded.
</description>
<display-name>Successful New User Registration</display-name>
<from-action>#{userBean.register}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>/welcome.jsp</to-view-id>
</navigation-case>
<navigation-case>
<description>
User registration for a new user failed because of a
duplicate username.
</description>
<display-name>Failed New User Registration</display-name>
<from-action>#{userBean.register}</from-action>
<from-outcome>duplicateUserName</from-outcome>
<to-view-id>/try-another-name.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<description>
Assume there is a search form on every page. These navigation
cases get merged with the application-wide rules above because
they use the same “from-view-id” pattern. The same thing would
also happen if “from-view-id” was omitted here, because that is
equivalent to a matching pattern of “*”.
</description>
<from-view-id> * </from-view-id>
<navigation-case>
<display-name>Search Form Success</display-name>
<from-action>#{searchForm.go}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>/search-results.jsp</to-view-id>
</navigation-case>
<navigation-case>
<display-name>Search Form Failure</display-name>
<from-action>#{searchForm.go}</from-action>
<to-view-id>/search-problem.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<description>
Searching works slightly differently in part of the site.
</description>
<from-view-id> /movies/* </from-view-id>
<navigation-case>
<display-name>Search Form Success</display-name>
<from-action>#{searchForm.go}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>/movie-search-results.jsp</to-view-id>
</navigation-case>
<navigation-case>
<display-name>Search Form Failure</display-name>
<from-action>#{searchForm.go}</from-action>
<to-view-id>/search-problem.jsp</to-view-id>
</navigation-case>
</navigation-rule>
7.5 ViewHandler
ViewHandler is the pluggability mechanism for allowing implementations of or
applications using the JavaServer Faces specification to provide their own handling of the
activities in the Render Response and Restore View phases of the request processing
lifecycle. This allows for implementations to support different response generation
technologies, as well as different state saving/restoring approaches.
7.5.1 Overview
ViewHandler defines the public APIs described in the following paragraphs
The initView() method must be called as the first method in the implementation of the
Restore View Phase of the request processing lifecycle, immediately after checking for the
existence of the FacesContext parameter. The default implementation of initView()
calls through to calculateCharacterEncoding(). If this returns non-null,
initView() sets the request character encoding using the ExternalContext method
setRequestCharacterEncoding().
Create and return a new UIViewRoot instance, initialized with information from the
specified FacesContext and view identifier parameters.
If the view being requested is a Facelet view, the createView() method must ensure that
the UIViewRoot is fully populated with all the children defined in the PDL page before
createView() returns.
Returns a URL, suitable for encoding and rendering, that (if activated) will cause the JSF
request processing lifecycle for the specified viewId to be executed
Returns a URL, suitable for encoding and rendering, that (if activated) will retrieve the
specified web application resource.
This method must be called during the Render Response phase of the request processing
lifecycle. It must provide a valid ResponseWriter or ResponseStream instance,
storing it in the FacesContext instance for the current request (see Section 6.1.8
“ResponseStream and ResponseWriter”), and then perform whatever actions are required to
cause the view currently stored in the viewRoot of the FacesContext instance for the
This method must be called from the Restore View phase of the request processing
lifecycle. It must perform whatever actions are required to restore the view associated with
the specified FacesContext and viewId.
It is the caller’s responsibility to ensure that the returned UIViewRoot instance is stored in
the FacesContext as the new viewRoot property. In addition, if restoreView()
returns null (because there is no saved state for this view identifier), the caller must call
createView(), and call renderResponse() on the FacesContext instance for this
request.
Take any appropriate action to either immediately write out the current view’s state
information (by calling StateManager.writeState()), or noting where state
information may later be written. This method must be called once per call to the
encodeEnd() method of any renderer for a UIForm component, in order to provide the
ViewHandler an opportunity to cause saved state to be included with each submitted form
The specification of the default ViewHandler must execute the following algorithm, called
the “viewId derivation algorithm” for discussion, in the createView() and
restoreView()methods as called for below.
PENDING This section needs to be revised to account for the fact that JSP and Facelets are
the two supported Page Declaration Languages.
[P1-start createView() requirements] The createView() method must fulfill the following
responsibilities:
■ Calculate the viewId that corresponds to this request following the “The ViewId
derivation algorithm”.
■ If no viewId could be identified, or the viewId is exactly equal to the servlet mapping,
send the response error code SC_NOT_FOUND with a suitable message to the client.
■ Create a new UIViewRoot object instance
■ Conditionally copy the renderKitId and locale from any current view for the
current request (as described in the Javadocs for createView()).
■ If the page description language for the view being created is Facelets version 2.0, the
implementation must guarantee that the page is executed in such a way that the
UIComponent tree described in the PDL page is completely built and populated, rooted
at the new UIViewRoot instance created previously.
■ Return the newly created UIViewRoot. [P1-end]
[P1-start initView() requirements] The initView() method must fulfill the following
responsibilities:
■ Call calculateCharacterEncoding(). If the result is non-null pass the result to
the setRequestCharacterEncoding() method of the ExternalContext for
this FacesContext. [P1-end]
7.6 StateManager
StateManager directs the process of saving and restoring the view between requests. The
StateManager instance for an application is retrieved from the Application instance,
and therefore cannot know any details of the markup language created by the RenderKit
being used to render a view. Therefore, the StateManager utilizes a helper object (see
Section 8.3 “ResponseStateManager”), that is provided by the RenderKit implementation,
and is therefore aware of the markup language details. The JSF implementation must provide
a default StateManager implementation that supports the behavior described below.
7.6.1 Overview
Conceptually, the state of a view can be divided into two pieces:
■ Tree Structure. This includes component parent-child relationships, including facets.
■ Component State. This includes:
■ Component attributes and properties, and
The values of all component attributes and properties (as well as the saved state of attached
objects) must implement java.io.Serializable.
4. The implementation classes for attached object must include a public zero-arguments constructor.
[P1-start saveView() requirements] This method causes the tree structure and component
state of the view contained in the argument FacesContext to be collected, stored, and
returned in a java.lang.Object instance that must implement
java.io.Serializable. If null is returned from this method, there is no state to
save.[P1-end]
The returned object must represent the entire state of the view, such that a request processing
lifecycle can be run against it on postback. Special care must be taken to guarantee that
objects attached to component instances, such as listeners, converters, and validators, are also
saved. The StateHolder interface is provided for this reason.
This method must also enforce the rule that component ids within a NamingContainer
must be unique
Save the state represented in the specified Object instance, in an implementation dependent
manner.
Restore the tree structure and the component state of the view for this viewId to be
restored, in an implementation dependent manner. If there is no saved state information
available for this viewId, this method returns null.
[P1-start isSavingStateInClient() requirements] Return true if and only if the value of the
ServletContext init parameter named by the value of the constant
StateManager.STATE_SAVING_METHOD_PARAM_NAME is equal to the value of the
constant STATE_SAVING_METHOD_CLIENT. Return false otherwise. [P1-end]
Return the current view state as a String. [P1-start-getViewState] This method must call
ResposeStateManger.getViewState.[P1-end] Refer to Section 8.3
“ResponseStateManager” for more details.
7.7 PageDeclarationLanguage
PENDING
Create and return a ValueBinding that can be used to evaluate the specified value binding
expression. Call through to createValueExpression, passing the argument ref,
Object.class for the expectedType, and null for the fnMapper. To avoid
nondeterministic behavior, it is recommended that applications (or frameworks) wishing to
plug in their own resolver implementations do so before createValueBinding() is
called for the first time. This method has been deprecated for
createValueExpression() (Section 7.1.10 “Programmatically Evaluating
Expressions”
Create and return a MethodBinding that can be used to evaluate the specified method
binding expression, and invoke the specified method. The implementation must call through
to createMethodExpression, passing the given arguments, and wrap the result in a
MethodBinding implementation, returning it. The method that is invoked must have
parameter signatures that are compatible with the classes in the params parameter5 (which
may be null or a zero-length array if the method to be called takes no parameters). The
actual parameters to be passed when the method is executed are specified on the invoke()
call of the returned MethodBinding instance.
Special version of the factory for UIComponent instances that is used when evaluating
component binding expression properties. The implementation of this method must wrap the
argument componentBinding in an implementation of ValueExpression and call
through to createComponent(javax.el.ValueExpression,
javax.faces.FacesContext, java.lang.String). This method has been
deprecated for createComponent() using ValueExpression (see Section 7.1.11 “Object
Factories”)
5. The actual Method selected for execution must be selected as if by calling Class.getMethod() and passing the method
name and the parameters signature specified in the createMethodBinding() call.
This method must also enforce the rule that component ids within a NamingContainer
must be unique
This method must create a Serializable object that represents the tree structure of the
component tree for this view. Tree structure is comprised of parent-child relationships,
including facets. The id of each component and facet must also be saved to allow the
naming containers in the tree to be correctly restored when this view is restored.
This method must create a Serializable object representing the component state
(attributes, properties, and attached objects) of the component tree for this view. Attached
objects that wish to save and restore their own state must implement StateHolder.
7.9.7 ResponseStateManager
This method causes the tree structure and component state of the view contained in the
argument FacesContext to be collected, stored, and returned in a
StateManager.SerializedView instance. If null is returned from this method,
there is no state to save.
The implementation must inspect the current request and return the tree structure Object
passed to it on a previous invocation of writeState()..
The implementation must inspect the current request and return the component state Object
passed to it on a previous invocation of writeState().
Rendering Model
JavaServer Faces supports two programming models for decoding component values from
incoming requests, and encoding component values into outgoing responses - the direct
implementation and delegated implementation models. When the direct implementation
model is utilized, components must decode and encode themselves. When the delegated
implementation programming model is utilized, these operations are delegated to a
Renderer instance associated (via the rendererType property) with the component.
This allows applications to deal with components in a manner that is predominantly
independent of how the component will appear to the user, while allowing a simple operation
(selection of a particular RenderKit) to customize the decoding and encoding for a
particular client device or localized application user.
Component writers, application developers, tool providers, and JSF implementations will
often provide one or more RenderKit implementations (along with a corresponding library
of Renderer instances). In many cases, these classes will be provided along with the
UIComponent classes for the components supported by the RenderKit. Page authors will
generally deal with RenderKits indirectly, because they are only responsible for selecting
a render kit identifier to be associated with a particular page, and a rendererType
property for each UIComponent that is used to select the corresponding Renderer.
8.1 RenderKit
A RenderKit instance is optionally associated with a view, and supports components using
the delegated implementation programming model for the decoding and encoding of
component values. [P1-start-renderkit]Each JSF implementation must provide a default
RenderKit instance (named by the render kit identifier associated with the String constant
RenderKitFactory.HTML_BASIC_RENDER_KIT as described below) that is utilized if
no other RenderKit is selected.[P1-end]
Applications that wish to go beyond the capabilities of the standard RenderKit that is
provided by every JSF implementation may either choose to create their own RenderKit
instances and register them with the RenderKitFactory instance (see Section 8.4
“RenderKitFactory”), or integrate additional (or replacement) supported Renderer
instances into an existing RenderKit instance. For example, it will be common for an
application that requires custom component classes and Renderers to register them with
the standard RenderKit provided by the JSF implementation, at application startup time
See Section 11.4.6 “Example Application Configuration Resource”for an example of a
faces-config.xml configuration resource that defines two additional Renderer instances
to be registered in the default RenderKit.
Use the provided Writer to create a new ResponseWriter instance for the specified
character encoding.
The contentTypeList parameter is an "Accept header style" list of content types for this
response, or null if the RenderKit should choose the best fit. [P1-start-
contentTypeList]The RenderKit must support a value for the contentTypeList
argument that comes straight from the Accept HTTP header, and therefore requires parsing
according to the specification of the Accept header.[P1-end] Please see Section 14.1 of
RFC 2616 (the HTTP 1.1 RFC) for the specification of the Accept header.
The first method returns an Iterator over the component-family entries supported by
this RenderKit. The second one can be used to get an Iterator over the renderer-
type entries for each of the component-family entries returned from the first method.
8.2 Renderer
A Renderer instance implements the decoding and encoding functionality of components,
during the Apply Request Values and Render Response phases of the request processing
lifecycle, when the component has a non-null value for the rendererType property.
For components utilizing the delegated implementation programming model, this method
will be called during the apply request values phase of the request processing lifecycle, for
the purpose of converting the incoming request information for this component back into a
new local value. See the API reference for the Renderer.decode() method for details on
its responsibilities.
Converts a component-generated client identifier into one suitable for transmission to the
client.
Return a flag indicating whether this Renderer is responsible for rendering the children of the
component it is asked to render.
Attempt to convert previously stored state information into an object of the type required for
this component (optionally using the registered Converter for this component, if there is
one). If conversion is successful, the new value should be returned from this method; if not,
a ConverterException should be thrown.
A Renderer may listen for events using the ListenerFor annotation. Refer to the
Javadocs for the ListenerFor class for more details.
[P1-start-getState]The implementation must inspect the current request and return the
component tree state Object passed to it on a previous invocation of writeState()[P1-end]
Take the argument state and write it into the output using the current ResponseWriter,
which must be correctly positioned already.
If the state is to be written out to hidden fields, the implementation must take care to make
all necessary character replacements to make the Strings suitable for inclusion as an HTTP
request parameter.
If the state saving method is client the implementation may encrypt the state to be saved to
the client. We recommend that the state be unreadable by the client, and also be tamper
evident.
Write out the render kit identifier associated with this ResponseStateManager
implementation with the name as the value of the String constant
ResponseStateManager.RENDER_KIT_ID_PARAM. [P1-start-
renderkitid]This render kit identifier must not be written if:
■ it is the default render kit identifier as returned by
Application.getDefaultRenderKitId() or
■ the render kit identifier is the value of
RenderKitFactory.HTML_BASIC_RENDER_KIT and
Application.getDefaultRenderKitId() returns null.[P1-end]
Return true if the current request is a postback. The default implementation returns true
if this ResponseStateManager instance wrote out state on a previous request to which
this request is a postback. Return false otherwise.
Return the view state as a String without any markup related to the rendering technology
supported by this ResponseStateManager.
8.4 RenderKitFactory
[P1-start-renderkitFactory]A single instance of
javax.faces.render.RenderKitFactory must be made available to each JSF-
based web application running in a servlet or portlet container.[P1-end] The factory instance
can be acquired by JSF implementations, or by application code, by executing
Return a RenderKit instance for the specified render kit identifier, possibly customized
based on the dynamic characteristics of the specified, (yet possibly null) FacesContext.
For example, an implementation might choose a different RenderKit based on the “User-
This method returns an Iterator over the set of render kit identifiers supported by this
factory. [P1-start-renderkitIds]This set must include the value specified by
RenderKitFactory.HTML_BASIC_RENDER_KIT.[P1-end]
Register a RenderKit instance for the specified render kit identifier, replacing any previous
RenderKit registered for that identifier.
The required behavior of the standard HTML RenderKit is specified in a set of external
HTML pages that accompany this specification, entitled “The Standard HTML RenderKit”.
The behavior described in these pages is normative, and are required to be fulfilled by all
implementations of JSF.
javax.faces.component javax.faces.component.html
class renderer-type class
javax.faces.component javax.faces.component.html
class renderer-type class
Any JavaServer Faces implementations that claims compliance with this specification must
include a complete JavaServer Pages implementation, and expose this implementation to the
runtime of any JSF application. JSF applications, however, need not use JSP as their Page
Declaration Language (PDL). In fact, a JSF application is free to use whatever technology it
likes for its PDL, as long as that PDL itself complies with the JSF specification.
This chapter describes the JSP support required by JavaServer Faces. This JSP support is
enabled by providing custom actions so that a JSF user interface can be easy defined in a JSP
page by adding tags corresponding to JSF UI components. Custom actions provided by a JSF
implementation may be mixed with standard JSP actions and custom actions from other
libraries, as well as template text for layout, in the same JSP page.
For JSP version 2.0 and onward, the file extension “.jsf” is reserved, and may optionally
be used (typically by authoring tools) to represent JSP pages containing JSF content1. When
running in a JSP 1.2 environment, JSP authors must give their JSP pages that contain JSF
content a filename ending in “.jsp”.
1. If this extension is used, it must be declared in the web application deployment descriptor, as described in the JSP 2.0 (or
later) specification.
“Text” “size”
“Secret” “size”, “secretChar”
“Textarea” “size”, “rows”
<tag>
<name>inputText</name>
<tag-class>acme.html.tags.InputTag</tag-class>
<bodycontent>JSP</bodycontent>
<attribute>
<name>id</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>value</name>
<required>false</required>
<deferred-value>
<type>java.lang.Object</type>
<deferred-value>
</attribute>
<attribute>
<name>size</name>
<required>false</required>
<deferred-value>
<type>java.lang.Integer</type>
<deferred-value>
</attribute>
...
</tag>
Note that the size attribute is derived from the Renderer of type “Text”, while the id and
value attributes are derived from the UIInput component class itself. Also note that the
id attribute has rtexprvalue set to true. This is to allow ${} expressions in the id
attribute so that <c:forEach> can include faces components that incorporate the index into
their id. RenderKit implementors will generally provide a JSP tag library which includes
component custom actions corresponding to each of the component classes (or types)
supported by each of the RenderKit’s Renderers. See Section 8.1 “RenderKit” and
Section 8.2 “Renderer” for details on the RenderKit and Renderer APIs. JSF
implementations must provide such a tag library for the standard HTML RenderKit (see
Section 9.5 “Standard HTML RenderKit Tag Library”).
2. This example illustrates a non-normative convention for naming custom actions based on a combination of the
component name and the renderer type. This convention is useful, but not required; custom actions may be given any
desired custom action name; however the convention is rigorously followed in the Standard HTML RenderKit Tag
Library.
The page author must use the standard JSP taglib directive to declare the URI of each tag
library to be utilized, as well as the prefix used (within this page) to identify custom actions
from this library. For example,
declares the unique resource identifiers of the tag libraries being used, as well as the prefixes
to be used within the current page for referencing actions from these libraries3.
3. Consistent with the way that namespace prefixes work in XML, the actual prefix used is totally up to the page author,
and has no semantic meaning. However, the values shown above are the suggested defaults, which are used consistently
in tag library examples throughout this specification.
represents a UIInput field, to be rendered with the “Text” renderer type, and points to the
username property of a backing bean for the actual value. The id attribute specifies the
component id of a UIComponent instance, from within the component tree, to which this
custom action corresponds. If no id is specified, one will be automatically generated by the
custom action implementation.
During the Render Response phase of the request processing lifecycle, the appropriate
encoding methods of the component (or its associated Renderer) will be utilized to
generate the representation of this component in the response page. In addition, the first time
a particular page is rendered, the component tree may also be dynamically constructed.
All markup other than UIComponent custom actions is processed by the JSP container, in
the usual way. Therefore, you can use such markup to perform layout control, or include non-
JSF content, in conjunction with the actions that represent UI components.
<h:form id=”logonForm”>
<h:panelGrid columns=”2”>
<h:outputLabel for=”username”>
<h:outputText value=”Username:”/>
</h:outputLabel>
<h:inputText id=”username”
value=”#{logonBean.username}”/>
<h:outputLabel for=”password”>
<h:outputText value=”Password:”/>
</h:outputLabel>
<h:inputSecret id=”password”
value=”#{logonBean.password}”/>
<h:commandButton id=”submitButton” type=”SUBMIT”
action=”#{logonBean.logon}”/>
<h:commandButton id=”resetButton” type=”RESET”/>
</h:panelGrid>
</h:form>
Using these facilities, the page author can manage all aspects of creating and configuring
values associated with the view, without having to resort to Java code. For example:
associates a validation check (that the value entered by the user must contain at least six
characters) with the username UIInput component being described.
<h:inputText id=”maxUsers”>
<f:convertNumber integerOnly=”true”/>
<f:valueChangeListener
type="custom.MyValueChangeListener"/>
</h:inputText>
<h:commandButton label="Login">
<f:actionListener type="custom.MyActionListener"/>
</h:commandButton>
<h:dataTable ...>
<f:facet name=”header”>
<h:outputText value=”Customer List”/>
</f:facet>
<h:column>
<f:facet name=”header”>
<h:outputText value=”Account Id”/>
</f:facet>
<h:outputText id=”accountId” value=
”#{customer.accountId}”/>
</h:column>
...
</h:dataTable>
4. If you need multiple components in a facet, nest them inside a <h:panelGroup> custom action that is the value of the
facet.
5. In a JSP 2.0 or later environment, the same effect can be accomplished by using <include-prelude> and <include-coda>
elements in the <jsp-config> element in the web application deployment descriptor.
■ For each non-null custom action attribute that corresponds to a method based attribute
to be set on the underlying component, the value of the attribute must be a method
reference expression. We have a number of wrapper classes to turn a
MethodExpression into the appropriate listener. For example, assume that
valueChangeListener is the name of an attribute for this component:
The definition of each UIComponent custom action in the corresponding tag library
descriptor (TLD) must conform to the following requirements:
■ The <body-content> element for the custom action itself must specify JSP.
■ For each attribute that is intended to be passed on to the underlying faces component:
■ The attribute may not be named id. This name is reserved for Faces use.
It’s very important to note that we still are using #{} as the delimiters for expressions that
appear in a JSP page in the value of a tag attribute, but when the Java API is used, either ${}
or #{} may be used for delimiters.
1. that JSP pages using the standard h: and f: tags must work without change
2. that JSP pages using custom faces taglibs must work without change
The first item is enabled by re-writing the h: and f: taglibs which must be provided by the
Faces implementor.
The second item is enabled as follows. For discussion the term jsp-version is used to
denote the jsp-version element in a JSP 1.2 (and earlier) TLD, as well as the version
element in a JSP 2.0 (and later) TLD. The JSP container must examine the jsp-version
element of the TLD for a taglib. If the jsp-version is less than 2.1, the taglib is deemed
to be a Faces 1.0 or 1.1 taglib and the container must ignore all expressions that use #{} as
delimiters, except for those appearing in tag attribute with a property setter that takes a
javax.el.ValueExpression or javax.el.MethodExpression. If the jsp-
version is 2.1 or greater, the taglib is deemed to be a Faces 1.2 or later taglib and the JSP
container is aware of #{} expressions.
[P1-start no javascript in jsf_core taglib] The tags in the implementation of this tag library
must not cause JavaScript to be rendered to the client. Doing so would break the requirement
that the JSF Core Tag library is independent of any specific RenderKit. [P1-end]
Each custom action included in the JSF Core Tag Library is documented in a subsection
below, with the following outline for each action:
■ Name—The name of this custom action, as used in a JSP page.
■ Short Description—A summary of the behavior implemented by this custom action.
■ Syntax—One or more examples of using this custom action, with the required and
optional sets of attributes that may be used together. If the tag may have an id attribute,
its value may be a literal string, or an immediate, non-defferd expression, such as
“userName” or “user${i}” without the quotes.
■ Body Content—The type of nested content for this custom action, using one of the
standard values empty, JSP, or tagdependent as described in the JSP specification.
This section also describes restrictions on the types of content (template text, JSF core
custom actions, JSF UIComponent custom actions, and/or other custom actions) that can
be nested in the body of this custom action.
■ Attributes—A table containing one row for each defined attribute for this custom action.
The following columns provide descriptive information about each attribute:
■ Name—Name of this attribute, as it must be used in the page. If the name of the
attribute is in italics, it is required.
■ Expr—The type of dynamic expression (if any) that can be used in this attribute value.
Legal values are VE (this may be a literal or a value expression), ME (this may be a
method expression), or NONE (this attribute accepts literal values only). If the Expr
column is VE, the corresponding <attribute> declaration in the TLD must contain
a <deferred-value> element, optionally containing a <type> element that
contains the fully qualified java class name of the expected type of the expression. If
<type> is omitted, Object.class is assumed. If the Expr column is ME, the
corresponding <attribute> declaration in the TLD must contain a <deferred-
method> element, containing a <method-signature> element that describes the
exact method signature for the method. In this case, the Description column the
description column contains the method signature.
■ Type—Fully qualified Java class or primitive type of this attribute.
■ Description—The functional meaning of this attribute’s value.
■ Constraints—Additional constraints enforced by this action, such as combinations of
attributes that may be used together.
■ Description—Details about the functionality provided by this custom action.
Syntax
<f:actionListener type=”fully-qualified-classname” binding=”value
Expression”/>
Body Content
empty.
Attributes
Constraints
■ Must be nested inside a UIComponent custom action.
■ The corresponding UIComponent implementation class must implement
ActionSource, and therefore define a public addActionListener() method that
accepts an ActionListener parameter.
■ The specified listener class must implement
javax.faces.event.ActionListener.
■ type and/or binding must be specified.
Description
If the listener instance could not be created, check the type attribute. If the type
attribute is set, instantiate an instance of the specified class, and register it by calling
addActionListener(). If the binding attribute was also set, evaluate the expression
into a ValueExpression and store the listener instance by calling setValue() on the
ValueExpression. If there was an exception thrown, rethrow the exception as a
JspException.
As an alternative to using the binding and/or type attributes, you may also register a
method in a backing bean class to receive ActionEvent notifications, by using the
actionListener attribute on the corresponding UIComponent custom action.
Syntax
<f:attribute name=”attribute-name” value=”attribute-value”/>
Body Content
empty.
Attributes
Constraints
■ Must be nested inside a UIComponent custom action.
Description
There is no standard implementation class for this action. It must be provided by the
implementation.
Syntax
<f:convertDateTime
[dateStyle=”{default|short|medium|long|full}”]
[locale=”{locale” | string}]
[pattern=”pattern”]
[timeStyle=”{default|short|medium|long|full}”]
[timeZone=”{timeZone| string}”]
[type=”{date|time|both}”]
[binding=”Value Expression”]/>
Body Content
empty.
Constraints
Description
Syntax
<f:convertNumber
[currencyCode=”currencyCode”]
[currencySymbol=”currencySymbol”]
[groupingUsed=”{true|false}”]
[integerOnly=”{true|false}”]
[locale=”locale”]
[maxFractionDigits=”maxFractionDigits”]
[maxIntegerDigits=”maxIntegerDigits”]
[minFractionDigits=”minFractionDigits”]
[minIntegerDigits=”minIntegerDigits”]
[pattern=”pattern”]
[type=”{number|currency|percent}”]
[binding=”Value Expression”]/>
Body Content
empty.
Constraints
■ Must be nested inside a UIComponent custom action whose component class
Description
[P1-start f:convertNumber implementation] The implementation class for this action must
meet the following requirements:
■ Must extend javax.faces.webapp.ConverterELTag.
■ The createConverter() method must:
■ If binding is non-null, call binding.getValue() to obtain a reference to the
Converter instance. If there is no exception thrown, and binding.getValue()
returned a non-null object that implements javax.faces.convert.Converter, it must
then cast the returned instance to javax.faces.convert.NumberConverter and
configure its properties based on the specified attributes for this custom action, and return
the configured instance. If there was an exception thrown, rethrow the exception as a
JspException.
■ use the converterId if the converter instance could not be created from the binding
attribute. Call the createConverter() method of the Application instance for
this application, passing converter id “javax.faces.Number”. If the binding attribute was
also set, store the converter instance by calling binding.setValue(). It must then
cast the returned instance to javax.faces.convert.NumberConverter and
configure its properties based on the specified attributes for this custom action, and return
the configured instance. If there was an exception thrown, rethrow the exception as a
JspException. [P1-end]
Syntax
<f:converter converterId=”converterId” binding=”Value Expression”/>
Body Content
empty
Attributes
Constraints
■ Must be nested inside a UIComponent custom action whose component class
implements ValueHolder.
■ converterId and/or binding must be specified.
[P1-start f:converter constraints] If this tag is not nested inside a UIComponent custom
action, or the UIComponent implementation class does not correctly implement
ValueHolder, throw a JspException. [P1-end]
Description
[P1-start f:converter implementation] The implementation class for this action must meet the
following requirements:
■ Must extend javax.faces.webapp.ConverterJspTag.
■ The createConverter() method must:
Syntax
<f:facet name=”facet-name”/>
Body Content
JSP. However, only a single UIComponent custom action (and any related nested JSF custom
actions) is allowed; no template text or other custom actions may be present.
Attributes
Constraints
■ [P1-start f:facet constraints] Must be nested inside a UIComponent custom action.
■ Exactly one UIComponent custom action must be nested inside this custom action
(although the nested component custom action could itself have nested children). [P1-end]
Description
Syntax
<f:loadBundle basename=”resource-bundle-name” var=”attributeKey”/>
Body Content
empty
Attributes
Constraints
■ [P1-start f:loadBundle constraints] Must be nested inside an <f:view> custom action.
[P1-end]
Description
Load the resource bundle specified by the basename attribute, localized for the Locale of
the UIViewRoot component of the current view, and expose its key-values pairs as a Map
under the attribute key specified by the var attribute. In this way, value binding expressions
may be used to conveniently retrieve localized values. If the named bundle is not found,
throw JspException.
If the get() method for the Map instance exposed by this custom action is passed a key
value that is not present (that is, there is no underlying resource value for that key), the literal
string “???foo???” (where “foo” is replaced by the key the String representation of the key
that was requested) must be returned, rather than the standard Map contract return value of
null.
Syntax
Body Content
empty.
Attributes
Constraints
■ [P1-start f:param constraints] Must be nested inside a UIComponent custom action. [P1-
end]
[P1-start f:param implementation] The implementation class for this action must meet the
following requirements:
■ Must extend javax.faces.UIComponentELTag.
■ The getComponentType() method must return “Parameter”.
■ The getRendererType() method must return null. [P1-end]
Syntax
<f:phaseListener type=”fully-qualified-classname”
binding=”Value expression”/>
Body Content
empty.
Attributes
Constraints
■ [P1-start f:phaseListener constraints] Must be nested inside a UIViewRoot custom
action.
■ The specified listener class must implement javax.faces.event.PhaseListener.
■ type and/or binding must be specified. [P1-end]
Description
Locate the one and only UIViewRoot custom action instance by walking up the tag tree
until you find a UIComponentTagBase instance that has no parent. If the
getCreated() method of this instance returns true, check the binding attribute.
Syntax
Body Content
empty
Constraints
■ [P1-start f:selectItem constraints] Must be nested inside a UIComponent custom action
that creates a UISelectMany or UISelectOne component instance.[P1-end]
Description
[P1-start f:selectItem implementation] The implementation class for this action must meet the
following requirements:
■ Must extend javax.faces.UIComponentELTag.
■ The getComponentType() method must return “SelectItem”.
■ The getRendererType() method must return null.[P1-end]
Syntax
<f:selectItems [id=”componentIdOrImmediateExpression”]
[binding=”componentReference”]
value=”selectItemsValue”/>
Body Content
empty
Attributes
Constraints
■ Must be nested inside a UIComponent custom action that creates a UISelectMany or
UISelectOne component instance.
[P1-start f:selectItems implementation]The implementation class for this action must meet
the following requirements:
■ Must extend javax.faces.UIComponentELTag.
■ The getComponentType() method must return “javax.faces.SelectItems”.
■ The getRendererType() method must return null. [P1-end]
Syntax
<f:setPropertyActionListener target=”Value Expression” value=”value
Expression”/>
Body Content
empty.
Attributes
Constraints
■ Must be nested inside a UIComponent custom action.
■ The corresponding UIComponent implementation class must implement
ActionSource, and therefore define a public addActionListener() method that
accepts an ActionListener parameter.
■ The tag implementation must only create and register the ActionListener instance
the first time the component for this tag is created
■ When the listener executes:
■ Call getValue() on the "value" ValueExpression.
■ If value of the "value" expression is null, call setValue()on the "target"
ValueExpression with the null value.
■ If the value of the "value" expression is not null, call getType()on the "value" and
"target" ValueExpressions to determine their property types.
■ Coerce the value of the "value" expression to the "target" expression value type
following the Expression Language coercion rules. Call setValue()on the "target"
ValueExpression with the resulting value.
Description
Syntax
<f:subview id=”componentIdOrImmediateExpression”
[binding=”componentReference”]
[rendered=”{true|false}”]>
Nested template text and custom actions
</f:subview>
Body Content
JSP. May contain any combination of template text, other JSF custom actions, and custom
actions from other custom tag libraries.
Attributes
Constraints
■ [P1-start f:subview constraints] Must be nested inside a <f:view> custom action
(although this custom action might be in a page that is including the page containing the
<f:subview> custom action.
■ Must not contain an <f:view> custom action.
■ Must have an id attribute whose value is unique within the scope of the parent naming
container.
■ May be placed in a parent page (with <jsp:include> or <c:import> nested inside),
or within the nested page. [P1-end]
“main.jsp”
<f:view>
<c:import url=”foo.jsp”/>
<c:import url=”bar.jsp”/>
</f:view>
“foo.jsp”
<f:subview id=”aaa”>
... components and other content ...
</f:subview>
“bar.jsp”
<f:subview id=”bbb”>
... components and other content ...
</f:subview>
“main.jsp”
<f:view>
<f:subview id=”aaa”>
<c:import url=”foo.jsp”/>
</f:subview>
<f:subview id=”bbb”>
<c:import url=”bar.jsp”/>
</f:subview>
</f:view>
“foo.jsp”
... components and other content ...
“bar.jsp”
... components and other content ...
In this scenario, the <f:subview> custom actions are in the including page, rather than
the included page. As in the previous scenario, the “id” values of the two subviews must be
unique; but it is much easier to verify using this style.
It is also possible to use this approach to include the same page more than once, but maintain
unique identifiers:
“main.jsp”
<f:view>
<f:subview id=”aaa”>
<c:import url=”foo.jsp”/>
</f:subview>
<f:subview id=”bbb”>
<c:import url=”foo.jsp”/>
</f:subview>
</f:view>
“foo.jsp”
... components and other content ...
In all of the above examples, note that foo.jsp and bar.jsp may not contain
<f:view>.
Syntax
Body Content
empty.
Attributes
Constraints
■ Must be nested inside a EditableValueHolder custom action whose value is (or is
convertible to) a double.
■ Must specify either the maximum attribute, the minimum attribute, or both.
■ If both limits are specified, the maximum limit must be greater than the minimum limit.
Description
Syntax
Body Content
empty.
Attributes
Constraints
■ Must be nested inside a EditableValueHolder custom action whose value is a
String.
■ Must specify either the maximum attribute, the minimum attribute, or both.
■ If both limits are specified, the maximum limit must be greater than the minimum limit.
[P1-start f:validateLength implementation] The implementation class for this action must
meet the following requirements:
■ Must extend javax.faces.webapp.ValidatorELTag.
■ The createValidator() method must:
■ If binding is non-null, create a ValueExpression by invoking
Application.createValueExpression() with binding as the expression
argument, and Validator.class as the expectedType argument.use the
ValueExpression to obtain a reference to the Validator instance. If there is no
exception thrown, and ValueExpression.getValue() returned a non-null object
that implements javax.faces.validator.Validator, it must then cast the returned
instance to javax.faces.validator.LengthValidator and configure its
properties based on the specified attributes for this custom action, and return the
configured instance. If there was an exception thrown, rethrow the exception as a
JspException.
■ use the validatorId if the validator instance could not be created from the
binding attribute. Call the createValidator() method of the Application
instance for this application, passing validator id “javax.faces.Length”. If the binding
attribute was also set, evaluate the expression into a ValueExpression and store
the validator instance by calling setValue() on the ValueExpression. It must
then cast the returned instance to javax.faces.validator.LengthValidator
and configure its properties based on the specified attributes for this custom action, and
return the configured instance. If there was an exception thrown, rethrow the exception
as a JspException.[P1-end]
Syntax
Body Content
empty.
Attributes
Constraints
■ Must be nested inside a EditableValueHolder custom action whose value is (or is
convertible to) a long.
■ Must specify either the maximum attribute, the minimum attribute, or both.
■ If both limits are specified, the maximum limit must be greater than the minimum limit.
Description
The implementation class for this action must meet the following requirements:
■ Must extend javax.faces.webapp.ValidatorELTag.
■ The createValidator() method must:
■ If binding is non-null, create a ValueExpression by invoking
Application.createValueExpression() with binding as the expression
argument, and Validator.class as the expectedType argument. Use the
ValueExpression to obtain a reference to the Validator instance. If there is no
exception thrown, and ValueExpression.getValue() returned a non-null object
that implements javax.faces.validator.Validator, it must then cast the returned
instance to javax.faces.validator.LongRangeValidator and configure
its properties based on the specified attributes for this custom action, and return the
configured instance. If there was an exception thrown, rethrow the exception as a
JspException.
■ use the validatorId if the validator instance could not be created from the
binding attribute. Call the createValidator() method of the Application
instance for this application, passing validator id “javax.faces.LongRange”. If the
binding attribute was also set, evaluate the expression into a ValueExpression
and store the validator instance by calling setValue() on the
ValueExpression. It must then cast the returned instance to
javax.faces.validator.LongRangeValidator and configure its properties
based on the specified attributes for this custom action, and return the configured
instance. If there was an exception thrown, rethrow the exception as a
JspException.
Syntax
<f:validator validatorId=”validatorId” binding=”VB Expression”/>
Body Content
empty
Attributes
Constraints
■ Must be nested inside a UIComponent custom action whose component class
implements EditableValueHolder.
■ validatorId and/or binding must be specified.
[P1-start f:validator constraints 2] If this tag is not nested inside a UIComponent custom
action, or the UIComponent implementation class does not correctly implement
EditableValueHolder throw a JspException. [P1-end]
Description
The implementation class for this action must meet the following requirements:
■ Must extend javax.faces.webapp.ValidatorJspTag.
■ The createValidator() method must:
Syntax
<f:valueChangeListener type=”fully-qualified-classname” binding=”VB
Expression”/>
Body Content
empty.
Attributes
Constraints
■ Must be nested inside a UIComponent custom action.
■ The corresponding UIComponent implementation class must implement
EditableValueHolder, and therefore define a public
addValueChangeListener() method that accepts an ValueChangeListener
parameter.
■ The specified listener class must implement
javax.faces.event.ValueChangeListener.
■ type and/or binding must be specified.
Description
If the listener instance could not be created, check the type attribute. If the type
attribute is set, instantiate an instance of the specified class, and register it by calling
addValueChangeListener(). If the binding attribute was also set, store the listener
instance by calling binding.setValue(). If there was an exception thrown, rethrow the
exception as a JspException.
As an alternative to using the binding and/or type attributes, you may also register a
method in a backing bean class to receive ValueChangeEvent notifications, by using the
valueChangeListener attribute on the corresponding UIComponent custom
action.instantiate an instance of the specified class, and register it by calling
addValueChangeListener().
Syntax
<f:verbatim [escape=”{true|false}” rendered=”{true|false”]/>
Body Content
JSP. However, no UIComponent custom actions, or custom actions from the JSF Core Tag
Library, may be nested inside this custom action.
Attributes
Constraints
■ [P1-start f:verbatim constraints] Must be implemented as a UIComponentBodyTag.[P1-
end]
Description
Syntax
Body Content
JSP. May contain any combination of template text, other JSF custom actions, and custom
actions from other custom tag libraries.
Attributes
renderKitId VE String The identifier for the render kit to use for
rendering this page.
locale VE String Name of a Locale to use for localizing this page
or (such as en_uk), or value binding expression that
Locale returns a Locale instance
beforePhase ME String MethodExpression expression that points to a
method whose signature is that of
javax.faces.event.PhaseListener.beforePha
se()
afterPhase ME String MethodExpression expression that points to a
method whose signature is that of
javax.faces.event.PhaseListener.afterPhas
e()
Constraints
■ [P1-start f:view constraints] Any JSP-created response using actions from the JSF Core
Tag Library, as well as actions extending
javax.faces.webapp.UIComponentELTag from other tag libraries, must be
nested inside an occurrence of the <f:view> action.
Description
Provides the JSF implementation a convenient place to perform state saving during the
render response phase of the request processing lifecycle, if the implementation elects to
save state as part of the response.
The implementation class for this action must meet the following requirements:
■ Must extend javax.faces.UIComponentELTag.
■ The getComponentType() method must return “ViewRoot”.
■ The getRendererType() method must return null.
[P1-start html_basic return values]The custom actions defined in this tag library must specify
the following return values for the getComponentType() and getRendererType()
methods, respectively:.
[P1-end] [P1-start html_basic taglibrary requirements 2]The tag library descriptor for this tag
library (and the corresponding tag handler implementation classes) must meet the following
requirements:
Pages are A Servlet that gets executed each An abstract syntax tree that, when
compiled to... time the page renders. The executed, builds a UIComponent
UIComponent hierarchy is built by hierarchy.
the presence of custom tags in the
page.
Mapping of Not enforceable by the run-time. Page Enforced by the run-time by
custom tags to authors are free to do things eliminating the need for a custom tag
UIComponent incorrectly and make non-compatible handler in most cases.
instances components.
Handling of tag All tag attributes must be declared in Tag attributes are completely dynamic
attributes a TLD file. Conformance instances of and automatically map to properties,
components in a page with the attributes and ValueExpressions on
expected attributes can be enforced UIComponent instances
with a taglibrary validator.
Page templating Not supported, must go outside of Page templating is a core feature of
core JSP Facelets
Performance Due to the common implementation Facelets is simpler and faster than
technique of compiling a JSP page to JSP
a Servlet, performance can be slow
EL Expressions Expressions in template text cause Expressions in template text operate
unexpected behavior when used in as expected.
JSP
JCP Standard Yes, the specification is separate from No, the specification is defined by
the implementation for JSP and is one with the implementation.
Thankfully, most applications that use Facelets fall into the latter category, or, if they fall in
the former, their dependence will easily be migrated to the new public classes.
Facelets in JSF 2.0 provides tag libraries that are compatible with the following libraries
already found in pre JSF 2.0 Facelets.
TABLE 10-2 Taglibs in pre JSF 2.0 Facelets that are available in Facelets in JSF 2.0
h http://java.sun.com/jsf/core
f http://java.sun.com/jsf/html
c http://java.sun.com/jsp/jstl/core
fn http://java.sun.com/jsp/jstl/functions
ui http://java.sun.com/jsf/facelets
Naturally, new features built on Facelets in JSF 2.0 are not available in pre JSF 2.0 Facelets
and will only work in JSF 2.0 or later.
[P1-end]
Portable JSF-based web applications must include the following configuration elements, in
the appropriate portions of the web application deployment descriptor. Element values that
are rendered in italics represent values that the application developer is free to choose.
Element values rendered in bold represent values that must be utilized exactly as shown.
Executing the request processing lifecycle via other mechanisms is also allowed (for
example, an MVC-based application framework can incorporate calling the correct phase
implementations in the correct order); however, all JSF implementations must support the
functionality described in this chapter to ensure application portability.
<servlet>
<servlet-name> faces-servlet-name </servlet-name>
<servlet-class>
javax.faces.webapp.FacesServlet
</servlet-class>
</servlet>
The servlet name, denoted as faces-servlet-name above, may be any desired value;
however, the same value must be used in the servlet mapping (see Section 11.1.2 “Servlet
Mapping”).[P1-end]
In addition to FacesServlet, JSF implementations may support other ways to invoke the
JavaServer Faces request processing lifecycle, but applications that rely on these mechanisms
will not be portable.
<servlet-mapping>
<servlet-name> faces-servlet-name </servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name> faces-servlet-name </servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
In addition to FacesServlet, JSF implementations may support other ways to invoke the
JavaServer Faces request processing lifecycle, but applications that rely on these mechanisms
will not be portable.
In addition, servlet and portlet containers typically provide mechanisms to share classes and
resources across one or more web applications, without requiring them to be included inside
the web application itself.
11.2.6.1 FactoryFinder
javax.faces.FactoryFinder implements the standard discovery algorithm for all
factory objects specified in the JavaServer Faces APIs. For a given factory class name, a
corresponding implementation class is searched for based on the following algorithm. Items
are listed in order of decreasing search precedence:
3. If there are any META-INF/faces-config.xml resources bundled any JAR files in the web
ServletContext’s resource paths, the factory entries of the given factory class
name in those files are used, with the last one taking precedence.
5. If none of the above steps yield a match, the JavaServer Faces implementation specific
class is used.
If any of the factories found on any of the steps above happen to have a one-argument
constructor, with argument the type being the abstract factory class, that constructor is
invoked, and the previous match is passed to the constructor. For example, say the container
vendor provided an implementation of FacesContextFactory, and identified it in
META-INF/services/javax.faces.context.FacesContextFactory in a jar
on the webapp ClassLoader. Also say this implementation provided by the container vendor
had a one argument constructor that took a FacesContextFactory instance. The
FactoryFinder system would call that one-argument constructor, passing the
implementation of FacesContextFactory provided by the JavaServer Faces
implementation.
JSF implementations must also include implementations of the several factory classes. In
order to be dynamically instantiated according to the algorithm defined above, the factory
implementation class must include a public, no-arguments constructor. [P1-start-
factoryNames]Factory class implementations must be provided for the following factory
names:
■ javax.faces.application.ApplicationFactory
(FactoryFinder.APPLICATION_FACTORY)—Factory for Application instances.
■ javax.faces.context.FacesContextFactory
(FactoryFinder.FACES_CONTEXT_FACTORY)—Factory for FacesContext
instances.
■ javax.faces.lifecycle.LifecycleFactory
(FactoryFinder.LIFECYCLE_FACTORY)—Factory for Lifecycle instances.
■ javax.faces.render.RenderKitFactory
(FactoryFinder.RENDER_KIT_FACTORY)—Factory for RenderKit instances.[P1-
end]
11.2.6.2 FacesServlet
FacesServlet is an implementation of javax.servlet.Servlet that accepts
incoming requests and passes them to the appropriate Lifecycle implementation for
processing. This servlet must be declared in the web application deployment descriptor, as
described in Section 11.1.1 “Servlet Definition”, and mapped to a standard URL pattern as
described in Section 11.1.2 “Servlet Mapping”.
11.2.6.4 FacetTag
JSP custom action that adds a named facet (see Section 3.1.9 “Facet Management”) to the
UIComponent associated with the closest parent UIComponent custom action. See
Section 9.4.6 “<f:facet>”.
11.2.6.5 ValidatorTag
JSP custom action (and convenience base class) that creates and registers a Validator
instance on the UIComponent associated with the closest parent UIComponent custom
action. See Section 9.4.14 “<f:validateDoubleRange>”, Section 9.4.15 “<f:validateLength>”,
Section 9.4.16 “<f:validateLongRange>”, and Section 9.4.17 “<f:validator>”.
11.3.1 AttributeTag
[P1-start-attributetag]The faces implementation must now provide this class.[P1-end]
11.3.2 ConverterTag
This has been replaced with ConverterELTag
11.3.4 UIComponentTag
This component has been replaced by UIComponentELTag.
11.3.5 ValidatorTag
This component has been replaced by ValidatorELTag.
11.4.1 Overview
JSF defines a portable configuration resource format (as an XML document) for standard
configuration information. One or more such application resources will be loaded
automatically, at application startup time, by the JSF implementation. The information parsed
from such resources will augment the information provided by the JSF implementation, as
described below.
In addition to their use during the execution of a JSF-based web application, configuration
resources provide information that is useful to development tools created by Tool Providers.
The mechanism by which configuration resources are made available to such tools is outside
the scope of this specification.
At application startup time, before any requests are processed, the [P1-start-startup]JSF
implementation must process zero or more application configuration resources, located
according to the following algorithm:
■ Search for all resources named “META-INF/faces-config.xml” in the
ServletContext resource paths for this web application, and load each as a JSF
configuration resource (in reverse order of the order in which they are returned by
getResources() on the current Thread’s ContextClassLoader).
■ Check for the existence of a context initialization parameter named
javax.faces.CONFIG_FILES. If it exists, treat it as a comma-delimited list of
context relative resource paths (starting with a “/”), and load each of the specfied
resources.
■ Check for the existence of a web application configuration resource named “/WEB-
INF/faces-config.xml”, and load it if the resource exists.[P1-end]
This algorithm provides considerable flexibility for developers that are assembling the
components of a JSF-based web application. For example, an application might include one
or more custom UIComponent implementations, along with associated Renderers, so it
can declare them in an application resource named “/WEB-INF/faces-config.xml”
with no need to programmatically register them with Application instance. In addition,
the application might choose to include a component library (packaged as a JAR file) that
includes a “META-INF/faces-config.xml” resource. The existence of this resource
causes components, renderers, and other JSF implementation classes that are stored in this
library JAR file to be automatically registered, with no action required by the application.
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
Application configuration resources that are written to run on JSF 1.2 Application
configuration resources must include the following schema declaration and must conform to
the schema referenced in the schemalocation URI shown below:
Application configuration resources that are written to run on JSF 1.1 implementations must
use the DTD declaration and include the following DOCTYPE declaration:
Application configuration resources that are written to run on JSF 1.0 implementations must
use the DTD declaration for the 1.0 DTD contained in the binary download of the JSF
reference implementation. They must also use the following DOCTYPE declaration:[P1-end]
For components, converters, and validators, it is legal to replace the implementation class
that is provided (by the JSF implementation) by default. This is accomplished by specifying
the standard value for the <component-type>, <converter-id>, or <validator-
id> that you wish to replace, and specifying your implementation class. To avoid class cast
exceptions, the replacement implementation class must be a subclass of the standard class
being replaced. For example, if you declare a custom Converter implementation class for
the standard converter identifier javax.faces.Integer, then your replacement class
must be a subclass of javax.faces.convert.IntegerConverter.
The following XML elements cause the replacement of the default implementation class for
the corresponding functionality, provided by the JSF implementation. See Section 11.4.5
“Delegating Implementation Support” for more information about the classes referenced by
these elements:
The following XML elements cause the replacement of the default implementation class for
the corresponding functionality, provided by the JSF implementation. Each of the referenced
classes must have a public zero-arguments constructor:
The following XML elements cause the addition of event listeners to standard JSF
implementation objects, as follows. Each of the referenced classes must have a public zero-
arguments constructor.
■ /faces-config/lifecycle/phase-listener -- Instantiate a new instance of the specified class,
which must implement PhaseListener, and register it with the Lifecycle instance
for the current web application.
In addition, the following XML elements influence the runtime behavior of the JSF
implementation, even though they do not cause registration of objects that are visible to a
JSF-based application.
■ /faces-config/managed-bean -- Make the characteristics of a managed bean with the
specified managed-bean-name available to the default VariableResolver
implementation.
■ /faces-config/navigation-rule -- Make the characteristics of a navigation rule available to
the default NavigationHandler implementation.
public MyViewHandler() { }
The second constructor will get called as the application is initially configured by the JSF
implementation, and the previously registered ViewHandler will get passed to it.
In version 1.2, we added new wrapper classes to make it easier to override a subset of the
total methods of the class and delegate the rest to the previous instance. We provide wrappers
for javax.faces.application.ViewHandler,
javax.faces.application.StateManager, and
javax.faces.context.ResponseWriter. For example, you could have a faces-
config.xml file that contains the following:
package com.foo;
import javax.faces.application.ViewHandler;
import javax.faces.application.ViewHandlerWrapper;
package com.foo;
import javax.faces.application.StateManager;
import javax.faces.application.StateManagerWrapper;
<?xml version=”1.0”?>
<faces-config version="1.2" xmlns=
"http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
<!-- Define our custom component -->
<component>
<description>
A custom component for rendering user-selectable dates in
various formats.
</description>
<display-name>My Custom Date</display-name>
<component-type>Date</component-type>
<component-class>
com.example.components.DateComponent
</component-class>
</component>
<!-- Define two renderers that know how to deal with dates -->
<render-kit>
<!-- No render-kit-id, so add them to default RenderKit -->
<renderer>
<display-name>Calendar Widget</display-name>
<component-family>MyComponent</component-family>
<renderer-type>MyCalendar</renderer-type>
<renderer-class>
com.example.renderers.MyCalendarRenderer
</renderer-class>
</renderer>
<renderer>
<display-name>Month/Day/Year</display-name>
<renderer-type>MonthDayYear</renderer-type>
<renderer-class>
com.example.renderers.MonthDayYearRenderer
</renderer-class>
</renderer>
</render-kit>
</faces-config>
The annotations fall into two categories: annotations related to artifacts that reside in a page
and annotations related to artifacts that do not reside in a page.
Lifecycle Management
In Chapter 2 “Request Processing Lifecycle,” the required functionality of each phase of the
request processing lifecycle was described. This chapter describes the standard APIs used by
JSF implementations to manage and execute the lifecycle. Each of these classes and
interfaces is part of the javax.faces.lifecycle package.
Page authors, component writers, and application developers, in general, will not need to be
aware of the lifecycle management APIs—they are primarily of interest to tool providers and
JSF implementors.
12.1 Lifecycle
Upon receipt of each JSF-destined request to this web application, the JSF implementation
must acquire a reference to the Lifecycle instance for this web application, and call its
execute() and render() methods to perform the request processing lifecycle. The
Lifecycle instance invokes appropriate processing logic to implement the required
functionality for each phase of the request processing lifecycle, as described in Section 2.2
“Standard Request Processing Lifecycle Phases”.
The execute() method performs phases up to, but not including, the Render Response
phase. The render() method performs the Render Response phase. This division of
responsibility makes it easy to support JavaServer Faces processing in a portlet-based
environment.
As each phase is processed, registered PhaseListener instances are also notified. The
general processing for each phase is as follows:
12.2 PhaseEvent
This class represents the beginning or ending of processing for a particular phase of the
request processing lifecycle, for the request encapsulated by the FacesContext instance
passed to our constructor.
Return the properties of this event instance. The specified FacesContext instance will
also be returned if getSource() (inherited from the base EventObject class) is called.
12.3 PhaseListener
This interface must be implemented by objects that wish to be notified before and after the
processing for a particular phase of the request processing lifecycle, on a particular request.
Implementations of PhaseListener must be programmed in a thread-safe manner.
The PhaseListener instance indicates for which phase of the request processing lifecycle
this listener wishes to be notified. If PhaseId.ANY_PHASE is returned, this listener will be
notified for all standard phases of the request processing lifecycle.
The beforePhase() method is called before the standard processing for a particular phase is
performed, while the afterPhase() method is called after the standard processing has been
completed. The JSF implementation must guarantee that, if beforePhase() has been
called on a particular instance, then afterPhase() will also be called, regardless of any
Exceptions that may have been thrown during the actual execution of the lifecycle phase. For
example, let’s say there are three PhaseListeners attached to the lifecycle: A, B, and C, in
that order. A.beforePhase() is called, and executes successfully. B.beforePhase()
is called and throws an exception. Any exceptions thrown during the beforePhase()
listeners must be caught, logged, and swallowed. In this example, C.beforePhase()
must not be called. Then the actual lifecycle phase executes. Any exceptions thrown during
12.4 LifecycleFactory
A single instance of javax.faces.lifecycle.LifecycleFactory must be made
available to each JSF-based web application running in a servlet or portlet container. The
factory instance can be acquired by JSF implementations or by application code, by
executing:
Register a new Lifecycle instance under the specified lifecycle identifier, and make it
available via calls to the getLifecycle method for the remainder of the current web
application’s lifetime.
Every JSF implementation must provide a Lifecycle instance for a default lifecycle
identifier that is designated by the String constant
LifecycleFactory.DEFAULT_LIFECYCLE. For advanced uses, a JSF implementation
may support additional lifecycle instances, named with unique lifecycle identifiers.
This method returns an iterator over the set of lifecycle identifiers supported by this factory.
This set must include the value specified by
LifecycleFactory.DEFAULT_LIFECYCLE.
Ajax Integration
This chapter of the specification describes how Ajax integrates with the JavaServer Faces
framework to create dynamic web applications. JavaServer Faces 1.2 standardized portions
of the architecture to facilitate building Web 2.0 applications with Ajax. This chapter
describes the resources and JavaScript APIs that are used to expose the Ajax capabilities of
JavaServer Faces to page authors and component authors. It also describes the necessary
ingredients of a JavaServer Faces Ajax framework, namely, a resource delivery mechanism,
partial tree traversal, partial page update.
For more information on this approach refer to Section 2.6.2.1 “Relocatable Resources” and
Section 2.6.2.2 “Resource Rendering Using Annotations”.
Script resources are relocatable resources (see Section 2.6.2.1 “Relocatable Resources”)
which means you can control the rendering location for these resources by setting the
“target” attribute on the resource component:
When the component is added to the view, an event will be published. This event handling
method will add the component resource to one of the resource location facets under the
view root so it will be in place before rendering.
<f:view contentType=”text/html”/>
<h:head>
<meta...
<title...
</h:head>
<h:body>
...
<h:outputScript name=”ajax.js” library=”javax.faces”
target=”body”/>
...
</h:body>
...
The Open Ajax Alliance is an organization of leading vendors, open source projects, and
companies using Ajax. Their prime objective is to accelerate customer success with Ajax,
through the use of open standards. The Open Ajax Registry is an industry-wide Ajax
registration authority managed by the OpenAjax Alliance. The Registry maintains industry-
wide lists of Ajax runtime libraries to help prevent object collisions.
There is a top level namespace javax that is registered with the Open Ajax Alliance:
Java Ajax: {
namespaceURI:"http://www.sun.com",
version:"1.0",
globals_to_approve:["javax"],
comments: "Used in the JSF 2.0 specification.",
specificationURI:"http://www.jcp.org/en/jsr/detail?id=316",
email: "[email protected]"
}
[P1-start openajax registration]To comply with the OpenAjax Alliance, libraries must register
themselves using OpenAjax.registerLibrary() at the time when the JavaScript files
are fetched and parsed by the browser’s JavaScript engine.
[P1-end]
[P1-start javascript namespace]Any page that intends to use the JavaServer Faces 2.0
JavaScript API must define a top level JavaScript object name javax, whose type is a
JavaScript associative array. Within that top level JavaScript object, found in the OpenAjax
[P1-end]
Collecting and encoding view state that will be sent to the server is a common operation used
by most JavaServer Faces Ajax frameworks. When a JavaServer Faces view is rendered, it
will contain a hidden field with the identifier javax.faces.ViewState whose value
contains the state for the current view. JSF Ajax clients collect additional view state,
combine it with the current view state and send it’s encoded form to the server.
javax.faces.Ajax.viewState(FORM_ELEMENT)
<ANY_HTML_OR_JSF_ELEMENT
on|EVENT|="javax.faces.Ajax.ajaxRequest(THIS, |event|,
{ |OPTIONS| });" />
THIS is the DOM element that triggered this Ajax request. The optional |event| argument
is the JavaScript event object. The optional |OPTIONS| argument is a JavaScript
associative object array that may contain the following name/value pairs:
Name Value
execute A comma seperated list of client identifiers. These reference the
components that will be processed during the “execute” phase of the
request processing lifecycle.
render A comma seperated list of client identifiers. These reference the
components that will be processed during the “render” phase of the request
processing lifecycle.
This use case assumes there is another component in the view with the identifier outtext.
[P1-start-projStage]This function must return the constant representing the current state of
the running application in a typical product development lifecycle. The returned value must
be the value returned from the server side method
javax.faces.application.Application.getProjectStage(); Refer to
Section 7.1.8 “ProjectStage Property” for more details about this property.[P1-end]
This chapter lists the latest XML Schema definition and Document Type Definition for JSF
metadata and config files.
<!--
The contents of this file are subject to the terms of either the GNU
may not use this file except in compliance with the License. You can
obtain
as provided by Sun in the GPL Version 2 section of the License file that
accompanied this code. If applicable, add the following below the License
Contributor(s):
If you wish your version of this file to be governed by only the CDDL or
elects to include this software in this distribution under the [CDDL or GPL
recipient has the option to distribute your version of this file under
either the CDDL, the GPL Version 2 or to extend the choice of license to
its licensees as provided above. However, if you add GPL Version 2 code
and therefore, elected the GPL Version 2 license, then the option applies
only if the new code is made subject to such option by the copyright
holder.
-->
<xsd:schema
targetNamespace="http://java.sun.com/xml/ns/javaee"
xmlns:javaee="http://java.sun.com/xml/ns/javaee"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
version="2.0">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:annotation>
<xsd:documentation>
Sun, Sun Microsystems, the Sun logo, Solaris, Java, Java EE,
</xsd:documentation>
</xsd:annotation>
<xsd:annotation>
<xsd:documentation>
<![CDATA[
Faces namespace:
http://java.sun.com/xml/ns/javaee
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="..."
version="2.0">
...
</faces-config>
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd
]]>
</xsd:documentation>
</xsd:annotation>
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:unique name="faces-config-converter-ID-uniqueness">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:selector xpath="javaee:converter"/>
<xsd:field xpath="javaee:converter-id"/>
</xsd:unique>
<xsd:annotation>
<xsd:documentation>
within a document.
</xsd:documentation>
</xsd:annotation>
<xsd:selector xpath="javaee:converter"/>
<xsd:field xpath="javaee:converter-for-class"/>
</xsd:unique>
<xsd:unique name="faces-config-validator-ID-uniqueness">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:selector xpath="javaee:validator"/>
<xsd:field xpath="javaee:validator-id"/>
</xsd:unique>
<xsd:unique name="faces-config-managed-bean-name-uniqueness">
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:selector xpath="javaee:managed-bean"/>
<xsd:field xpath="javaee:managed-bean-name"/>
</xsd:unique>
</xsd:element>
<xsd:complexType name="faces-configType">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:element name="application"
type="javaee:faces-config-applicationType"/>
type="javaee:faces-config-factoryType"/>
<xsd:element name="component"
type="javaee:faces-config-componentType"/>
<xsd:element name="converter"
type="javaee:faces-config-converterType"/>
<xsd:element name="managed-bean"
type="javaee:faces-config-managed-beanType"/>
<xsd:element name="navigation-rule"
type="javaee:faces-config-navigation-ruleType"/>
<xsd:element name="referenced-bean"
type="javaee:faces-config-referenced-beanType"/>
<xsd:element name="render-kit"
type="javaee:faces-config-render-kitType"/>
<xsd:element name="lifecycle"
type="javaee:faces-config-lifecycleType"/>
<xsd:element name="validator"
type="javaee:faces-config-validatorType"/>
<xsd:element name="faces-config-extension"
type="javaee:faces-config-extensionType"
minOccurs="0"
maxOccurs="unbounded"/>
</xsd:choice>
<xsd:attribute name="version"
type="javaee:faces-config-versionType"
use="required"/>
</xsd:complexType>
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:any namespace="##any"
processContents="lax"
minOccurs="0"
maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="faces-config-applicationType">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:element name="action-listener"
type="javaee:fully-qualified-classType">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:element name="default-render-kit-id"
type="javaee:string">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="message-bundle"
type="javaee:string">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:element name="navigation-handler"
type="javaee:fully-qualified-classType">
<xsd:annotation>
<xsd:documentation>
implementation) is used.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="view-handler"
type="javaee:fully-qualified-classType">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="state-manager"
type="javaee:fully-qualified-classType">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="el-resolver"
<xsd:annotation>
<xsd:documentation>
EL expressions.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="property-resolver"
type="javaee:fully-qualified-classType">
<xsd:annotation>
<xsd:documentation>
expressions.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
type="javaee:fully-qualified-classType">
<xsd:annotation>
<xsd:documentation>
expressions.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="resource-handler"
type="javaee:fully-qualified-classType">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element
name="locale-config"
type="javaee:faces-config-locale-configType"/>
<xsd:element
name="resource-bundle"
type="javaee:faces-config-application-resource-
bundleType"/>
<xsd:element name="application-extension"
type="javaee:faces-config-application-
extensionType"
minOccurs="0"
maxOccurs="unbounded"/>
</xsd:choice>
</xsd:complexType>
<xsd:complexType name="faces-config-application-resource-bundleType">
<xsd:annotation>
<xsd:documentation>
element below.
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:group ref="javaee:descriptionGroup"/>
<xsd:element name="base-name"
type="javaee:fully-qualified-classType">
<xsd:annotation>
<xsd:documentation>
java.util.ResourceBundle instance.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="var"
type="javaee:string">
<xsd:annotation>
<xsd:documentation>
Application.getResourceBundle().
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:any namespace="##any"
processContents="lax"
minOccurs="0"
maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
<xsd:annotation>
<xsd:documentation>
default.
</xsd:documentation>
</xsd:annotation>
<xsd:element name="application-factory"
type="javaee:fully-qualified-classType">
<xsd:annotation>
<xsd:documentation>
FactoryFinder.getFactory(APPLICATION_FACTORY) is
called.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="faces-context-factory"
type="javaee:fully-qualified-classType">
<xsd:annotation>
<xsd:documentation>
be called when
FactoryFinder.getFactory(FACES_CONTEXT_FACTORY)
is called.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="lifecycle-factory"
type="javaee:fully-qualified-classType">
<xsd:annotation>
<xsd:documentation>
FactoryFinder.getFactory(LIFECYCLE_FACTORY) is
called.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="render-kit-factory"
type="javaee:fully-qualified-classType">
<xsd:annotation>
<xsd:documentation>
FactoryFinder.getFactory(RENDER_KIT_FACTORY) is
called.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="factory-extension"
type="javaee:faces-config-factory-extensionType"
minOccurs="0"
maxOccurs="unbounded"/>
</xsd:choice>
</xsd:complexType>
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:any namespace="##any"
processContents="lax"
minOccurs="0"
maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="faces-config-attributeType">
<xsd:documentation>
attributes mechanism.
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:group ref="javaee:descriptionGroup"/>
<xsd:element name="attribute-name"
type="javaee:string">
<xsd:annotation>
<xsd:documentation>
to.
</xsd:annotation>
</xsd:element>
<xsd:element name="attribute-class"
type="javaee:fully-qualified-classType">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="default-value"
type="javaee:faces-config-default-valueType"
minOccurs="0"/>
<xsd:element name="suggested-value"
type="javaee:faces-config-suggested-valueType"
minOccurs="0"/>
<xsd:element name="attribute-extension"
type="javaee:faces-config-attribute-extensionType"
minOccurs="0"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:any namespace="##any"
processContents="lax"
minOccurs="0"
maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="faces-config-componentType">
<xsd:annotation>
<xsd:documentation>
via tools.
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:group ref="javaee:descriptionGroup"/>
<xsd:element name="component-type"
type="javaee:string">
<xsd:annotation>
<xsd:documentation>
registered.
</xsd:annotation>
</xsd:element>
<xsd:element name="component-class"
type="javaee:fully-qualified-classType">
<xsd:annotation>
<xsd:documentation>
implementation class.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="facet"
type="javaee:faces-config-facetType"
minOccurs="0"
maxOccurs="unbounded"/>
<xsd:element name="attribute"
type="javaee:faces-config-attributeType"
minOccurs="0"
maxOccurs="unbounded"/>
<xsd:element name="property"
type="javaee:faces-config-propertyType"
minOccurs="0"
maxOccurs="unbounded"/>
<xsd:element name="component-extension"
minOccurs="0"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="faces-config-component-extensionType">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:any namespace="##any"
processContents="lax"
minOccurs="0"
maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:simpleContent>
<xsd:extension base="javaee:faces-config-localeType">
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="faces-config-default-valueType">
<xsd:annotation>
<xsd:documentation>
value is optional.
</xsd:documentation>
</xsd:annotation>
<xsd:simpleContent>
<xsd:restriction base="javaee:string"/>
</xsd:simpleContent>
</xsd:complexType>
<xsd:simpleType name="faces-config-el-expressionType">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:pattern value="#`.*\}"/>
</xsd:simpleType>
<xsd:complexType name="faces-config-facetType">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:group ref="javaee:descriptionGroup"/>
<xsd:element name="facet-name"
type="javaee:java-identifierType">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:element>
<xsd:element name="facet-extension"
type="javaee:faces-config-facet-extensionType"
minOccurs="0"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="faces-config-facet-extensionType">
<xsd:annotation>
<xsd:documentation>
specific content.
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:any namespace="##any"
processContents="lax"
minOccurs="0"
maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="faces-config-from-view-idType">
<xsd:annotation>
<xsd:documentation>
values:
is selected.
</xsd:annotation>
<xsd:simpleContent>
<xsd:restriction base="javaee:string"/>
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="faces-config-from-actionType">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:simpleContent>
<xsd:extension base="javaee:faces-config-el-expressionType">
</xsd:extension>
</xsd:simpleContent>
<xsd:complexType name="faces-config-converterType">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:group ref="javaee:descriptionGroup"/>
<xsd:choice>
<xsd:element name="converter-id"
type="javaee:string">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="converter-for-class"
type="javaee:fully-qualified-classType">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
</xsd:choice>
<xsd:element name="converter-class"
type="javaee:fully-qualified-classType">
<xsd:annotation>
<xsd:documentation>
implementation class.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="attribute"
type="javaee:faces-config-attributeType"
minOccurs="0"
maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="property"
type="javaee:faces-config-propertyType"
minOccurs="0"
maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="converter-extension"
type="javaee:faces-config-converter-extensionType"
minOccurs="0"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:any namespace="##any"
processContents="lax"
minOccurs="0"
maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="faces-config-lifecycleType">
<xsd:annotation>
</xsd:documentation>
</xsd:annotation>
<xsd:element name="phase-listener"
type="javaee:fully-qualified-classType"
minOccurs="0"
maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
the Lifecycle.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="faces-lifecycle-listener"
type="javaee:faces-config-lifecycle-listenerType"
maxOccurs="unbounded">
</xsd:element>
<xsd:element name="lifecycle-extension"
type="javaee:faces-config-lifecycle-extensionType"
minOccurs="0"
maxOccurs="unbounded"/>
</xsd:choice>
</xsd:complexType>
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:any namespace="##any"
processContents="lax"
minOccurs="0"
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="faces-config-localeType">
<xsd:annotation>
<xsd:documentation>
and ISO-3166.
</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:pattern value="([a-z]{2})[_|]?([
{L}]{2})?[_|]?(\w+)?"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="faces-config-locale-configType">
<xsd:annotation>
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="default-locale"
type="javaee:faces-config-default-localeType"
minOccurs="0">
</xsd:element>
<xsd:element name="supported-locale"
type="javaee:faces-config-supported-localeType"
minOccurs="0"
maxOccurs="unbounded">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="faces-config-managed-beanType">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:group ref="javaee:descriptionGroup"/>
<xsd:element name="managed-bean-name"
type="javaee:java-identifierType">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:element>
<xsd:element name="managed-bean-class"
type="javaee:fully-qualified-classType">
<xsd:annotation>
<xsd:documentation>
property setters.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element
name="managed-bean-scope"
type="javaee:faces-config-managed-bean-scopeOrNoneType">
<xsd:annotation>
<xsd:documentation>
"none").
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:choice>
<xsd:element name="managed-property"
type="javaee:faces-config-managed-
propertyType"
minOccurs="0"
maxOccurs="unbounded"/>
<xsd:element name="map-entries"
type="javaee:faces-config-map-entriesType"/>
<xsd:element name="list-entries"
type="javaee:faces-config-list-entriesType"/>
</xsd:choice>
<xsd:element name="managed-bean-extension"
type="javaee:faces-config-managed-bean-
extensionType"
minOccurs="0"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:any namespace="##any"
processContents="lax"
minOccurs="0"
maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="faces-config-managed-bean-scopeOrNoneType">
<xsd:annotation>
<xsd:documentation>
any scope.
]]>
</xsd:documentation>
</xsd:annotation>
<xsd:simpleContent>
<xsd:restriction base="javaee:string">
<xsd:enumeration value="request"/>
<xsd:enumeration value="view"/>
<xsd:enumeration value="session"/>
<xsd:enumeration value="application"/>
<xsd:enumeration value="none"/>
</xsd:restriction>
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="faces-config-managed-propertyType">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:group ref="javaee:descriptionGroup"/>
<xsd:element name="property-name"
type="javaee:string">
<xsd:annotation>
<xsd:documentation>
be stored.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="property-class"
type="javaee:java-typeType"
minOccurs="0">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:choice>
<xsd:element name="map-entries"
type="javaee:faces-config-map-entriesType"/>
<xsd:element name="null-value"
type="javaee:faces-config-null-valueType">
</xsd:element>
<xsd:element name="value"
type="javaee:faces-config-valueType"/>
<xsd:element name="list-entries"
type="javaee:faces-config-list-entriesType"/>
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="key"
type="javaee:string">
<xsd:annotation>
<xsd:documentation>
type java.util.Map.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:choice>
<xsd:element name="null-value"
type="javaee:faces-config-null-valueType"/>
type="javaee:faces-config-valueType"/>
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="faces-config-map-entriesType">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="key-class"
type="javaee:fully-qualified-classType"
minOccurs="0">
<xsd:annotation>
<xsd:documentation>
is assumed.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="value-class"
type="javaee:faces-config-value-classType"
minOccurs="0"/>
<xsd:element name="map-entry"
type="javaee:faces-config-map-entryType"
minOccurs="0"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="faces-config-navigation-caseType">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:group ref="javaee:descriptionGroup"/>
<xsd:element name="from-action"
type="javaee:faces-config-from-actionType"
minOccurs="0">
</xsd:element>
<xsd:element name="from-outcome"
type="javaee:string" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="to-view-id"
type="javaee:string">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element
name="redirect"
type="javaee:faces-config-redirectType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="faces-config-navigation-ruleType">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:group ref="javaee:descriptionGroup"/>
<xsd:element name="from-view-id"
type="javaee:faces-config-from-view-idType"
minOccurs="0"/>
<xsd:element name="navigation-case"
type="javaee:faces-config-navigation-caseType"
minOccurs="0"
maxOccurs="unbounded"/>
<xsd:element
name="navigation-rule-extension"
type="javaee:faces-config-navigation-rule-extensionType"
minOccurs="0"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:any namespace="##any"
processContents="lax"
minOccurs="0"
maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="faces-config-null-valueType">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
</xsd:complexType>
<xsd:schema
targetNamespace="http://java.sun.com/xml/ns/javaee"
xmlns:javaee="http://java.sun.com/xml/ns/javaee"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
version="2.0">
<xsd:include schemaLocation="javaee_5.xsd"/>
<xsd:unique name="facelet-taglib-tagname-uniqueness">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:selector xpath="javaee:tag"/>
<xsd:field xpath="javaee:tag-name"/>
</xsd:unique>
<xsd:unique name="faces-config-converter-ID-
uniqueness">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:selector xpath="javaee:converter"/>
<xsd:field xpath="javaee:converter-id"/>
<xsd:unique name="faces-config-validator-ID-
uniqueness">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:selector xpath="javaee:validator"/>
<xsd:field xpath="javaee:validator-id"/>
</xsd:unique>
</xsd:element>
<xsd:complexType name="facelet-taglibType">
<xsd:choice>
<xsd:element name="library-class"
type="javaee:fully-qualified-
classType"/>
<xsd:choice>
<xsd:sequence>
name="composite-library-name"
type="javaee:fully-qualified-
classType"/>
<xsd:element name="tag"
<xsd:element name="function"
type="javaee:facelet-
taglib-functionType"/>
</xsd:choice>
</xsd:sequence>
</xsd:choice>
</xsd:choice>
<xsd:attribute name="version"
type="javaee:facelet-taglib-versionType"
use="required"/>
</xsd:complexType>
<xsd:complexType name="facelet-taglib-tagType">
<xsd:sequence>
<xsd:choice>
<xsd:element name="handler-class"
type="javaee:fully-qualified-
classType"/>
<xsd:element name="component"
type="javaee:facelet-taglib-
tag-componentType"/>
<xsd:element name="converter"
type="javaee:facelet-taglib-
tag-converterType"/>
<xsd:element name="validator"
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="facelet-taglib-functionType">
<xsd:sequence>
<xsd:element name="function-class"
type="javaee:fully-qualified-
classType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="facelet-taglib-tag-componentType">
<xsd:sequence>
name="renderer-type" type=
"javaee:string"/>
name="handler-class"
type="javaee:fully-qualified-
classType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:sequence>
name="converter-id" type=
"javaee:string"/>
name="handler-class" type=
"javaee:fully-qualified-classType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="facelet-taglib-tag-validatorType">
<xsd:sequence>
name="validator-id" type=
"javaee:string"/>
name="handler-class" type=
"javaee:fully-qualified-classType"/>
</xsd:sequence>
</xsd:complexType>
<!-- **************************************************** -
->
<xsd:simpleType name="facelet-taglib-versionType">
<xsd:annotation>
<xsd:documentation>
facelet-taglib supported.
</xsd:documentation>
</xsd:annotation>
<xsd:enumeration value="2.0"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
General changes
The numbers in the text below refer to issue numbers in the issue tracker found at
<https://javaserverfaces-spec-public.dev.java.net/servlets/ProjectIssues>.
■ 2 - Clarify that for client side state saving, the state should be encrypted for security.
■ 3 - Clarify the specification with respect to constraint violations for tags in the Core Tag
Library.
■ 4 - Added headerClass and footerClass attributes at the “h:column” level. Please
see Section 8.5 “Standard HTML RenderKit Implementation” for more details.
■ 5 - Clarified the use of a string literal for the “action” attribute on ActionSource
components.
■ 6 - Introduced a new optional “label” attribute for input components that will provide an
association between a component, and the message that the component (indirectly)
produced. Please refer to Section 8.5 “Standard HTML RenderKit Implementation” and
Section 2.5.2.4 “Localized Application Messages” for more details.
■ 8 - Made UViewRoot a source of PhaseEvent(s) for all phases of the request processing
lifecycle except RestoreView. Provided additional “before” and “after” phase listener
attributes for the <f:view> tag. Please see Section 4.1.17 “UIViewRoot” for more details.
■ 9 - Clarified the behavior of PhaseListener implementations in the following way: they
must guarantee that if “beforePhase()” is called, then “afterPhase()” must also be called,
regardless of any thrown exceptions. Please see Section 12.3 “PhaseListener” for more
specifics.
■ 11 - Provide a unique window identifier (in addition to the “viewid”) to accomodate
applications that have mutiple instances of the same view, but perhaps in different
browser windows or frames.
Following is a section by section breakdown of the main changes since the last release of this
document. This work was done mainly to support changes in tree creation and content
interweaving for JSP based faces applications, as well as for fixing the following issues from
the above list: 2 3 4 5 6 8 9 11 13 15 16 17 18 20 21 27 29 30 35 43 45 47 48 50 51 53 54
55 58 59 65 66 67 68 69 72 73 74 75 78 80 81 82 84 85 86 93 95 98 99 105 108 111 118 119
120 122 123 124 131 133 134 135 138 145 147 151 152 154 155 160.
Preface
■ Added new section: Guide to Deprecated Methods Relating to State Management and
their Corresponding Replacements.
Add new method, encodeAll(), which is now the preferred method for developers to call to
render a child or facet().