Over the chapters of this book, we have developed many recipes involving JSF and other technologies related to JSF. Usually, when a JSF-related technology gets into the equation, you need to add some specific configurations, you have to create a "bridge" between JSF and the technology used. This appendix contains the configurations for a few technologies.
Namespaces: http://myfaces.apache.org/trinidad (prefix: tr
)
http://myfaces.apache.org/trinidad/html (prefix: trh
)
A JSF web.xml
file configured for Apache MyFaces Trinidad may look like this (the bolded code is specific to Apache MyFaces Trinidad):
<?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" 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-app_3_0.xsd"> <!-- setting the project stage to be DEVELOPMENT --> <context-param> <param-name>javax.faces.PROJECT_STAGE</param-name> <param-value>Development</param-value> </context-param> <context-param> <param-name>javax.faces.DEFAULT_SUFFIX</param-name> <param-value>.jsp</param-value> </context-param> <!-- Temporary internal flag to set to enabled and test Optimized PPR --> <context-param> <param-name> org.apache.myfaces.trinidadinternal.ENABLE_PPR_OPTIMIZATION </param-name> <param-value>false</param-value> </context-param> <!-- In Trinidad, we use an optimized, token-based mechanism if either 1] javax.faces.STATE_SAVING_METHOD = server 2] javax.faces.STATE_SAVING_METHOD = client and org.apache.myfaces.trinidad.CLIENT_STATE_METHOD = token --> <context-param> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>client</param-value> <!--param-value>server</param-value--> </context-param> <!-- Temporarily disable partial state saving default until we make it work with Trinidad --> <context-param> <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name> <param-value>false</param-value> </context-param> <!-- Trinidad by default uses an optimized client-side state saving mechanism. To disable that, uncomment the following --> <!--context-param> <param-name>org.apache.myfaces.trinidad.CLIENT_STATE_METHOD </param-name> <param-value>all</param-value> </context-param--> <!-- Trinidad also supports an optimized strategy for caching some view state at an application level, which significantly improves scalability. However, it makes it harder to develop (updates to Apache MyFaces Trinidad (supports JSF 2.0)JSF web.xml configurationpages will not be noticed until the server is restarted), and in some rare cases cannot be used for some pages (see Trinidad documentation for more information) --> <context-param> <param-name> org.apache.myfaces.trinidad.USE_APPLICATION_VIEW_CACHE </param-name> <param-value>false</param-value> </context-param> <context-param> <param-name>org.apache.myfaces.trinidad.CACHE_VIEW_ROOT </param-name> <param-value>true</param-value> </context-param> <!-- If this parameter is enabled, Trinidad will automatically check the modification date of your JSPs, and discard saved state when they change; this makes development easier, but adds overhead that should be avoided when your application is deployed --> <context-param> <param-name> org.apache.myfaces.trinidad.CHECK_FILE_MODIFICATION </param-name> <param-value>false</param-value> </context-param> <!-- Enables Change Persistence at a session scope. By default, Change Persistence is entirely disabled. The ChangeManager is an API, which can persist component modifications (like, is a showDetail or tree expanded or collapsed). For providing a custom Change Persistence implementation inherit from the Trinidad API's ChangeManager class. As the value you have to use the fullqualified class name. --> <context-param> <param-name>org.apache.myfaces.trinidad.CHANGE_PERSISTENCE </param-name> <param-value>session</param-value> </context-param> <context-param> <param-name>org.apache.myfaces.trinidad.resource.DEBUG </param-name> <param-value>false</param-value> </context-param> <context-param> <param-name>org.apache.myfaces.trinidad.DEBUG_JAVASCRIPT </param-name> <param-value>true</param-value> </context-param> <filter> <filter-name>trinidad</filter-name> <filter-class> org.apache.myfaces.trinidad.webapp.TrinidadFilter </filter-class> </filter> <filter-mapping> <filter-name>trinidad</filter-name> <servlet-name>faces</servlet-name> </filter-mapping> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <!-- resource loader servlet --> <servlet> <servlet-name>resources</servlet-name> <servlet-class> org.apache.myfaces.trinidad.webapp.ResourceServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>/faces/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>resources</servlet-name> <url-pattern>/adf/*</url-pattern> </servlet-mapping> <session-config> <session-timeout> 30 </session-timeout> </session-config> <welcome-file-list> <welcome-file>faces/index.jsp</welcome-file> </welcome-file-list> </web-app>
A JSF faces-config.xml
configured for Apache MyFaces Trinidad may look like this (the bolded code is specific to Apache MyFaces Trindidad):
… <application> <!-- Use the Trinidad RenderKit --> <default-render-kit-id>org.apache.myfaces.trinidad.core</default-render-kit-id> <locale-config> <default-locale>en</default-locale> <supported-locale>ar</supported-locale> <supported-locale>ca</supported-locale> <supported-locale>cs</supported-locale> <supported-locale>da</supported-locale> <supported-locale>de</supported-locale> <supported-locale>el</supported-locale> <supported-locale>es</supported-locale> <supported-locale>es_ES</supported-locale> <supported-locale>fi</supported-locale> <supported-locale>fr</supported-locale> <supported-locale>fr_CA</supported-locale> <supported-locale>hr</supported-locale> <supported-locale>hu</supported-locale> <supported-locale>is</supported-locale> <supported-locale>it</supported-locale> <supported-locale>iw</supported-locale> <supported-locale>ja</supported-locale> <supported-locale>ko</supported-locale> <supported-locale>nl</supported-locale> <supported-locale>no</supported-locale> <supported-locale>pl</supported-locale> <supported-locale>pt</supported-locale> <supported-locale>pt_BR</supported-locale> <supported-locale>ro</supported-locale> <supported-locale>ru</supported-locale> <supported-locale>sk</supported-locale> <supported-locale>sv</supported-locale> <supported-locale>th</supported-locale> <supported-locale>tr</supported-locale> <supported-locale>zh_CN</supported-locale> <supported-locale>zh_TW</supported-locale> </locale-config> </application> …
Additionally, you need trinidad-config.xml
, like this:
<?xml version="1.0" encoding="UTF-8"?> <trinidad-config xmlns="http://myfaces.apache.org/trinidad/config"> <debug-output>true</debug-output> <accessibility-mode>default</accessibility-mode> <skin-family>simple</skin-family> </trinidad-config>