JBossWithJSFCDDL

Full JSF 1.2 Support

 

JBoss AS 4.2 and 5.x ship with the Common Development and Distribution License (CDDL) implementation (now called "Project Mojarra") of the JSF 1.2 specification that is available from the java.net open source community.

 

Here is a pretty good summary of the new features in JSF 1.2

 

Resource Injection for Managed Beans

In addition to the basic new JSF 1.2 features, JBoss adds resource injection and lifecycle methods for managed beans as required for JEE 5 compliant application servers.

 

If you use this feature, make sure that your web.xml is using the latest web-app version.  This should be at the top of your web.xml file :

 

 

 

<web-app version="2.5" 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_2_5.xsd"> 

 

How to use the integrated JSF 1.2 Support

 

If you like examples, there is a simple one here.

 

 

Before you begin, note: You should not add JSF implementation jars to your WAR!! Why?  Because the JSF JARs are currently provided in the deploy\jboss-web.deployer\jsf-libs folder.

 

 

 

All you need to do is add the Faces Servlet and a mapping to your web.xml:

<web-app> 
   <servlet>
      <servlet-name>javax.faces.FacesServlet</servlet-name>
      <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>             
   </servlet>   
   
   <servlet-mapping>
      <servlet-name>javax.faces.FacesServlet</servlet-name>
      <url-pattern>*.faces</url-pattern>
   </servlet-mapping>    
</web-app>

 

If JBoss doesn't find the

FacesServlet

defined in your web.xml then JSF functionality will be disabled for that web application.

 

 

Using JBossSerialization with JSF

If your JSF application uses client-side state saving then serialization cost is likely to be a major performance consideration.  Depending on the application and the JVM, JBossSerializationcan speed up JSF serialization considerably.  To enable use of JBossSerializationin your JSF application, simply add this to your web.xml:

 

<context-param>         
   <param-name>com.sun.faces.serializationProvider</param-name>
   <param-value>org.jboss.web.jsf.integration.serialization.JBossSerializationProvider</param-value>
</context-param>

 

 

Logging Considerations

The java.net CDDL JSF Implementation uses JDK logging.  If you are already using JdkLogging with JBoss, you can skip this section.

 

 

 

Most JBoss installations use the default logging mechanism, which is Log4J.  If Log4J is being used, JBoss converts the JDK-style log messages from the JSF implementation into Log4J messages.  This does not affect logging from applications.  It only converts the messages emitted from the JSF implementation.

 

 

 

Also, if you are using Log4J on JBoss 5, you can set the priority level of JSF implementation messages from log4.xml.  See JBossFacesLogging for details.

 

 

 

 

The JSF implementation can log many configuration messages at startup, including the value of every faces context param.  This is done for every JSF application, which can get pretty annoying.  So by default, these startup messages are supressed.  If you want to turn them back on, add this to your WEB-INF/web.xml:

 

   <context-param>
      <param-name>com.sun.faces.displayConfiguration</param-name>
      <param-value>true</param-value>
   </context-param>

 

 

JSF Configuration Params

 

Here are the context params you can use in your web.xml file to customize the way JSF behaves. The values shown here are the defaults:

   <context-param>
      <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
      <param-value>server</param-value>
   </context-param>

   <context-param>
      <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
      <param-value>.jsp</param-value>
   </context-param>

   <context-param>
      <param-name>com.sun.faces.numberOfViewsInSession</param-name>
      <param-value>15</param-value>
   </context-param>

   <context-param>
      <param-name>numberOfLogicalViews</param-name>
      <param-value>15</param-value>
   </context-param>

   <context-param>
      <param-name>com.sun.faces.verifyObjects</param-name>
      <param-value>false</param-value>
   </context-param>

   <context-param>
      <param-name>com.sun.faces.forceLoadConfiguration</param-name>
      <param-value>false</param-value>
   </context-param>

   <context-param>
      <param-name>com.sun.faces.disableVersionTracking</param-name>
      <param-value>false</param-value>
   </context-param>

   <context-param>
      <param-name>com.sun.faces.enableHtmlTagLibValidator</param-name>
      <param-value>false</param-value>
   </context-param>

   <context-param>
      <param-name>com.sun.faces.preferXHTML</param-name>
      <param-value>false</param-value>
   </context-param>

   <context-param>
      <param-name>com.sun.faces.compressViewState</param-name>
      <param-value>true</param-value>
   </context-param>

   <context-param>
      <param-name>com.sun.faces.responseBufferSize</param-name>
      <param-value>4096</param-value>
   </context-param>

   <context-param>
      <param-name>com.sun.faces.clientStateWriteBufferSize</param-name>
      <param-value>8192</param-value>
   </context-param>

   <context-param>
      <param-name>com.sun.faces.validateXml</param-name>
      <param-value>false</param-value>
   </context-param>

   <context-param>
      <param-name>com.sun.faces.displayConfiguration</param-name>
      <param-value>false</param-value>
   </context-param>

   <context-param>
      <description>Added in Mojarra 1.2_05.  See wiki.jboss.org/wiki/Wiki.jsp?page=UpgradeToMojarra1_2_08</description>
      <param-name>com.sun.faces.enableLazyBeanValidation</param-name>
      <param-value>true</param-value>
   </context-param>

   <context-param>
      <description>Added in Mojarra 1.2_05.  See wiki.jboss.org/wiki/Wiki.jsp?page=UpgradeToMojarra1_2_08</description>
      <param-name>com.sun.faces.enabledLoadBundle11Compatibility</param-name>
      <param-value>false</param-value>
   </context-param>

   <context-param>
      <description>Added in Mojarra 1.2_05.  See wiki.jboss.org/wiki/Wiki.jsp?page=UpgradeToMojarra1_2_08</description>
      <param-name>com.sun.faces.clientStateTimeout</param-name>
      <param-value>none</param-value>
   </context-param>

   <context-param>
      <description>Added in Mojarra 1.2_05.  See wiki.jboss.org/wiki/Wiki.jsp?page=UpgradeToMojarra1_2_08</description>
      <param-name>com.sun.faces.serializeServerState</param-name>
      <param-value>false</param-value>
   </context-param>

   <context-param>
      <description>Added in Mojarra 1.2_08.  See wiki.jboss.org/wiki/Wiki.jsp?page=UpgradeToMojarra1_2_08</description>
      <param-name>com.sun.faces.enableViewStateIdRendering</param-name>
      <param-value>true</param-value>
   </context-param>

   <context-param>
      <description>Added in Mojarra 1.2_08. See wiki.jboss.org/wiki/Wiki.jsp?page=UpgradeToMojarra1_2_08</description>
      <param-name>com.sun.faces.enableScriptsInAttributeValues</param-name>
      <param-value>true</param-value>
   </context-param>

   <context-param>
     <param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
     <param-value>false</param-value>
   </context-param> 

 

For an explanation of WAR_BUNDLES_JSF_IMPL click here.

 

Referenced by: