Differences between revisions 4 and 5
Revision 4 as of 2007-04-26 17:55:20
Size: 2132
Comment:
Revision 5 as of 2009-09-20 23:01:19
Size: 2132
Editor: localhost
Comment: converted to 1.6 markup
No differences found!

JSF Configuration Validation

Our JSF configuration files can grow a bit unruly on large projects. MyFaces provides a feature allowing for some easy cleanup.

Let's say we have the following in our deployment descriptor:

  <navigation-rule> 
    <from-view-id>/missing.jsp</from-view-id> 
    <navigation-case> 
      <from-action>#{UserLister.load}</from-action>
      <from-outcome>SUCCESS</from-outcome> 
      <to-view-id>/doesNotExist.jsp</to-view-id>
    </navigation-case> 
  </navigation-rule>

  <managed-bean>
        <managed-bean-name>missing</managed-bean-name>
        <managed-bean-class>org.apache.myfaces.Missing</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
  </managed-bean>

It appears an application developer has configured a navigation rule for two non-existing JSPs, and a managed bean that is not in the classpath.

We discover this after we place the following context parameter in the deployment descriptor.

   <context-param>
       <description>For JSF 1.1</description>
       <param-name>org.apache.myfaces.validate</param-name>
       <param-value>true</param-value>
   </context-param>
   <context-param>
       <description>For JSF 1.2</description>
       <param-name>org.apache.myfaces.VALIDATE</param-name>
       <param-value>true</param-value>
   </context-param>

At startup, we find the following in our logs/console:

WARN  org.apache.myfaces.webapp.StartupServletContextListener - File for navigation 'from id' does not exist D:\jakarta-tomcat-5.5.9\webapps\demo\/missing.jsp

WARN  org.apache.myfaces.webapp.StartupServletContextListener - File for navigation 'to id' does not exist D:\jakarta-tomcat-5.5.9\webapps\demo\/doesNotExist.jsp

WARN  org.apache.myfaces.webapp.StartupServletContextListener - Could not locate class org.apache.myfaces.Missing for managed bean 'missing'

INFO  org.apache.myfaces.webapp.StartupServletContextListener - ServletContext 'D:\jakarta-tomcat-5.5.9\webapps\demo\' initialized.

This feature was added after the MyFaces 1.1.1 release.

A_Little_Quality_Assurance (last edited 2009-09-20 23:01:19 by localhost)