Configuring Liberty for JavaServer Faces 2.3
You can configure Liberty for the JavaServer Faces (JSF) 2.3 feature, which provides full support for the JSF 2.3 specification.
About this task
The Liberty JSF implementation is based on
the MyFaces open source implementation. To configure a Liberty server to run an application that is
enabled for JSF 2.3, set the <jsf-2.3>
feature.
Procedure
Update the server.xml file to add the
<jsf-2.3>
feature: <featureManager>
<feature>jsf-2.3</feature>
</featureManager>
Important:
Consider the following points when you use JavaServer Faces 2.3:
- The JSF 2.3 feature requires Java™ 8 at minimum.
- Use the JSF 2.3 feature only with other Java EE 8 features and EE 7 features that do not have an
equivalent Java EE 8 version. For example, you can use the
jsf-2.3
feature with Servlet 4.0, but you cannot use it with the Servlet 3.1 feature. - The JSF 2.3 feature does not implicitly load the Contexts and Dependency Injection (CDI)
feature. To use the CDI functionality, enable the
cdi-2.0
feature. - If the
@FacesConfig
annotation is present in any of the managed beans, CDI performs the Expression Language (EL) resolution of implicit objects. See Section 5.6.3, CDI for EL Resolution, of the JSF 2.3 specification. - The JSF 2.3 feature does not implicitly load the bean
validation feature like the JSF 2.0 feature does. When you migrate your application from JSF 2.0 to
JSF 2.3, and your application uses bean validation, enable the
beanValidation-2.0
feature. - The JSF 2.3 feature does not implicitly load the WebSocket feature. To use the
<f:websocket/>
functionality, enable thewebsocket-1.1
feature. - The JSF 2.3 feature requires the
servlet-4.0
,jsp-2.3
, andel-3.0
features. When you enable the JSF 2.3 feature in the server.xml file, you also enable each of these features. - You can choose between the JSF 2.0, JSF 2.2, and JSF 2.3 feature implementations for each server instance. However, consider any behavior changes. If the necessary behavior is contained only in the JSF 2.3 feature, use the JSF 2.3 feature. If behavior changes in the JSF 2.3 feature adversely affect an existing application, use either the JSF 2.2 or JSF 2.0 feature to preserve the existing behavior for that application.
- You cannot use the JSF 2.0, JSF 2.2, and JSF 2.3 features in the same Liberty server. If you configure two or more
features, the program produces an
error:
CWWKF0033E: The singleton features jsf-2.2 and jsf-2.3 cannot be loaded at the same time. The configured features jsf-2.2 and jsf-2.3 include one or more features that cause the conflict. Your configuration is not supported; update server.xml to remove incompatible features.
- The JSF 2.3 feature is compatible with earlier releases, such as JSF 2.2, JSF 2.1, and JSF 2.0,
but some exceptions apply.
- The JSF 2.3 feature is not compatible with earlier releases if any of the following context
parameter values are specified in the web application deployment descriptor. For more information,
see Section 11.1.3, Application Configuration Parameters, in the JSF 2.3
specification.
javax.faces.ALWAYS_PERFORM_VALIDATION_WHEN_REQUIRED_IS_TRUE javax.faces.DISABLE_FACESSERVLET_TO_XHTML javax.faces.VIEWROOT_PHASE_LISTENER_QUEUES_EXCEPTIONS.
- The JSF 2.3 feature is not compatible with earlier releases if a bean that is managed by CDI is
included in the application with the annotation
@javax.faces.annotation.FacesConfig
. For more information, see the Java API information.
- The JSF 2.3 feature is not compatible with earlier releases if any of the following context
parameter values are specified in the web application deployment descriptor. For more information,
see Section 11.1.3, Application Configuration Parameters, in the JSF 2.3
specification.
- The JSF 2.3 feature does not support constructor injection in the following JSF artifacts. For
more information, see the JSF 2.3 specification issue.
javax.el.ELResolver
javax.faces.application.NavigationHandler
javax.faces.application.StateManager
javax.faces.application.ResourceHandler
javax.faces.event.ActionListener
javax.faces.event.PhaseListener
javax.faces.event.SystemEventListener
Results
What to do next
To support injection when you specify objects that JSF manages, such as FacesConverter, FacesValidator, and FacesBehavior, provide a beans.xml file.
To register DataModel implementations, place the
@FacesDataModel
annotation on a
class with a scope annotation or in an application with a beans.xml file with
the following
specifications:<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
bean-discovery-mode="all">
</beans>