7 Working with JSF and MyFaces Applications
This chapter includes the following sections:
- Configuring for all JSF and MyFaces Web Applications:
JSF and MyFaces attempts to cache the state of the view in the session object. - Configuring for Instrumented Applications that use MyFaces
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. - Configuring for Instrumented Applications that use Mojarra
If you are using Coherence*Web WebInstaller to deploy a Web application based on the JSF Reference Implementation (Mojarra), then you must declare theFacesServlet
class in theservlet
stanza of theweb.xml
file.
Configuring for all JSF and MyFaces Web Applications:
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 totrue
.
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 7-1 illustrates setting the STATE_SAVING_METHOD
parameter in the web.xml
file.
Example 7-1 Setting STATE_SAVING_METHOD in the web.xml File
... <context-param> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>client</param-value> </context-param> ...
Parent topic: Working with JSF and MyFaces Applications
Configuring for Instrumented Applications that use MyFaces
-
If you are using Coherence*Web WebInstaller to deploy a Web-application built with a pre-1.1.n 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 theweb.xml
file. This parameter allows you to specify a custom servlet instead of the defaultjavax.faces.webapp.FacesServlet
.Example 7-2 illustrates setting the
DELEGATE_FACES_SERVLET
context parameter in theweb.xml
file.
Example 7-2 Setting DELEGATE_FACES_SERVLET in the web.xml File
... <context-param> <param-name>org.apache.myfaces.DELEGATE_FACES_SERVLET</param-name> <param-value>com.tangosol.coherence.servlet.api23.ServletWrapper</param-value> </context-param> ...
Parent topic: Working with JSF and MyFaces Applications
Configuring for Instrumented Applications that use Mojarra
FacesServlet
class in the servlet
stanza of the web.xml
file.Example 7-3 Declaring the Faces Servlet in the web.xml File
... <servlet> <servlet-name>Faces Servlet (for loading config)</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> </servlet> ...
Parent topic: Working with JSF and MyFaces Applications