Manual for updating JSF 2.0 Project to 2.2
From the JSF 2.2. Reference implementation manual
Faces 2.2 is backwards compatible with Faces 2.1 and 2.0. This means that a web-application that was developed to run with Faces 2.1 or 2.0 won’t require any modification when run with Faces 2.2
Due to an error in previous versions of the specification, exceptions were silently being swallowed that now will bubble up to the exception handler. Code that was relying on this incorrect behavior may need to be modified to account for fixing this problem.
And also:
Any additional attributes on
<composite:attribute/>
are exposed as attributes accessible from thegetValue()
andattributeNames()
methods onPropertyDescriptor
. The return type fromgetValue()
must be a ValueExpression with the exception of the getValue(“type”). The return type fromgetValue(“type”)
must be Class. If the value specified for the type attribute of<cc:attribute/>
cannot be converted to an actual Class, aTagAttributeException
must be thrown, including theTag
andTagAttribute
instances in the constructor.
Conclusion: there is minimal breakage between JSF2.1. and 2.2.
EDIT: Some new things in JSF2.2:
-
New namespaces:
xmlns:f="http://xmlns.jcp.org/jsf/core"
can replacexmlns:f="http://java.sun.com/jsf/core"
and alsoxmlns:h="http://xmlns.jcp.org/jsf/html"
can replacexmlns:h="http://java.sun.com/jsf/html"
-
Based on your comment: The
preRenderView
event type from the following construct in JSF2.0:<f:metadata> <f:event type="preRenderView" listener="#{viewActionManagedBean.validateUser()}"/> </f:metadata>
Can be replaced with the following brand new
<f:viewAction/>
tag in JSF2.2:<f:metadata> <f:viewAction action="#{viewActionManagedBean.validateUser()}"/> </f:metadata>
This tag also provides support for executing the managed bean method during specific phases of the request lifecycle with the
phase
attribute. Valid options are- RESTORE_VIEW (Restore View)
- APPLY_REQUEST_VALUES(Apply Request Values)
- PROCESS_VALIDATIONS(Process Validations)
- UPDATE_MODEL_VALUES(Update Model Values)
- INVOKE_APPLICATION(Invoke Application)
- RENDER_RESPONSE(Render Response)
The tag also supports the
if
attribute that defines a boolean condition on which the action will be run. Take the following for example:<f:metadata> <f:viewAction action="#{viewActionManagedBean.validateUser()}" if="#{viewActionManagedBean.verifyCondition}" phase="APPLY_REQUEST_VALUES"/> </f:metadata>
Note that this tag is available only in the new namespace
xmlns:f="http://xmlns.jcp.org/jsf/core"
You can get your copy of the specification below. Look under the /Preface/Changes between 2.1. and 2.2. /Backwards Compatibility with Previous Versions
Niko
Updated on June 06, 2022Comments
-
Niko almost 2 years
unfortunately there are no working tutorials to update a Eclipse (KEPLER) JSF 2.0 Project to JSF 2.2. Should this update be done or should a new project be created (and import all files)?
What are the Steps to update the used JSF version properly and clean?
I'm just getting errors (from FactoryNotFound to StartupServletContextListener problems), when I change the faces.xml header to:
<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">
I additionally updated the library to Majorra 2.2.0 (JSF 2.2) and dynamic web project to 3.0 and java to 1.7 (in the preferences), but the server just prints errors and does not work...