Show TOC

Background documentationfaces-config.xml Locate this document in the navigation structure

 

Each JSF application needs a faces-config.xml configuration file. It describes the application properties, such as navigation rules between the JSF pages, default bean instances, default values of some variables, message bundles, and so on.

For example, here are some extracts of the faces-config.xml of our Java EE 5 Demo:

Syntax Syntax

  1. <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, 
    Inc.//DTD JavaServer Faces Config 1.0//EN"
    "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
    
    <faces-config>
    
      <application>
        <message-bundle>com.sap.engine.examples.EDMAppMessages</message-bundle>
        <locale-config>
          <default-locale>en</default-locale>
          <supported-locale>en</supported-locale>
        </locale-config>
      </application>
    
     <navigation-rule>
        <from-view-id>/deptList.jsp</from-view-id>
        <navigation-case>
          <from-outcome>departments_selected</from-outcome>
          <to-view-id>/deptDetails.jsp</to-view-id>
        </navigation-case>
      </navigation-rule>
    
      <navigation-rule>
        <from-view-id>/prjList.jsp</from-view-id>    
        <navigation-case>
          <from-outcome>show_create_project_page</from-outcome>
          <to-view-id>/prjCreate.jsp</to-view-id>
        </navigation-case>    
        <navigation-case>
          <from-outcome>show_project_details</from-outcome>
          <to-view-id>/prjDetails.jsp</to-view-id>
        </navigation-case>    
      </navigation-rule>
    
      . . .
    
      <!-- Page Objects -->
       <managed-bean>
        <description>
          Representing a list of departments.
        </description>
        <managed-bean-name>departmentList</managed-bean-name>
        <managed-bean-class>com.sap.engine.examples.backingbeans.
                             DepartmentListBean</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
      </managed-bean>
    
       <managed-bean>
        <description>
          Representing a list of projects.
        </description>
        <managed-bean-name>projectList</managed-bean-name>
        <managed-bean-class>com.sap.engine.examples.backingbeans.
                              ProjectListBean</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
      </managed-bean>
    
      . . .
    
      </faces-config>
    
End of the code.

The <application>...</application> part describes configuration information for the entire application. In our case, we placed the description of the message bundle implementation and the locales information.

The <navigation-rule>s specify under what conditions one page will lead to another. The values of the <from-outcome> tags are associated with the actions of command buttons. More information: Command Buttons.

The <managed-bean> sections describe the names of the default instances of the managed beans. They will be created initially by JSF, and can be used by all JSF pages. For example, this faces-config.xml describes that an instance of class com.sap.engine.examples.backingbeans.DepartmentListBeans will be created, and will have the name departmentList.