JavaServer Faces (JSF) is a framework that enables you to build user interfaces for Web applications. MyFaces, from the Apache Software Foundation, provides JSF components that extend the JSF specification. MyFaces components are completely compatible with the JSF 1.1 Reference Implementation or any other compatible implementation.
JSF and MyFaces attempts to cache the state of the view in the session object. This state data should be serializable by default, but there could be situations where this would not be the case. For example:
If Coherence*Web reports
IllegalStateException due to a non-serializable class, and all the attributes placed in the session by your Web-application are serializable, then you must configure JSF/MyFaces to store the state of the view in a hidden field on the rendered page.
If the Web application puts non-serializable objects in the session object, you must set the
coherence-preserve-attributes context parameter to
The JSF parameter
javax.faces.STATE_SAVING_METHOD identifies where the state of the view is stored between requests. By default, the state is saved in the servlet session. Set the
STATE_SAVING_METHOD parameter to
client in the
context-param stanza of the
web.xml file, so that JSF stores the state of the entire view in a hidden field on the rendered page. If you do not, then JSF may attempt to cache that state, which is not serializable, in the session object.
Example 9-1 illustrates setting the
STATE_SAVING_METHOD parameter in the
... <context-param> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>client</param-value> </context-param> ...
If you are deploying the MyFaces application with the Coherence*Web WebInstaller (that is, an instrumented application), then you might have to complete an additional step based on the version of MyFaces.
If you are using Coherence*Web WebInstaller to deploy a Web-application built with a pre-1.1.x version of MyFaces, then nothing more needs to be done.
If you are using Coherence*Web WebInstaller to deploy a Web-application built with a 1.2.x version of MyFaces, then add the context parameter
org.apache.myfaces.DELEGATE_FACES_SERVLET to the
web.xml file. This parameter allows you to specify a custom servlet instead of the default
Example 9-2 illustrates setting the
DELEGATE_FACES_SERVLET context parameter in the
If you are using Coherence*Web WebInstaller to deploy a Web application based on the JSF Reference Implementation (Mojarra), then you must declare the
FacesServlet class in the
servlet stanza of the
... <servlet> <servlet-name>Faces Servlet (for loading config)</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> </servlet> ...
If you are using the Coherence SPI to deploy a Web application built with MyFaces, then nothing more needs to be done. This is the recommended method of running MyFaces with Coherence*Web.
If you are using the Coherence SPI to deploy a Web application based on the JSF Reference Implementation (Mojarra), then nothing needs to be done. This is the recommended method of running JSF with Coherence*Web.