Download
FAQ History |
API
Search Feedback |
Application Configuration Resource File
JavaServer Faces technology provides a portable configuration format (as an XML document) for configuring resources. An application architect creates one or more files, called application configuration resource files, that use this format to register and configure objects and to define navigation rules. An application configuration resource file is usually called
faces-config.xml
.The application configuration resource file must be valid against the DTD located at
http://java.sun.com/dtd/web-facesconfig_1_0.dtd
. In addition, each file must include the following, in this order:
- The XML version number:
<?xml version="1.0"?>
- This
DOCTYPE
declaration at the top of the file:<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
"http://java.sun.com/dtd/web-facesconfig_1_0.dtd">- A
faces-config
tag enclosing all the other declarations:<faces-config>
...
</faces-config>You can have more than one application configuration resource files, and there are three ways that you can make these files available to the application. The JavaServer Faces implementation finds the file or files by looking for the following:
- A resource named
/META-INF/faces-config.xml
in any of the JAR files in the Web application's/WEB-INF/lib/
directory and in parent class loaders. If a resource with this name exists, it is loaded as a configuration resource. This method is practical for a packaged library containing some components and renderers.- A context init parameter,
javax.faces.application.CONFIG_FILES
,that specifies one or more (comma-delimited) paths to multiple configuration files for your Web application. This method will most likely be used for enterprise-scale applications that delegate to separate groups, the responsibility for maintaining the file for each portion of a big application.
- A resource named
faces-config.xml
in the/WEB-INF/
directory of your application if you don't specify a context init parameter. This is the way most simple applications will make their configuration files available.To access resources registered with the application, an application developer uses an instance of the
Application
class, which is automatically created for each application. TheApplication
class acts as a centralized factory for resources that are defined in the XML file.When an application starts up, the JavaServer Faces implementation creates a single instance of the
Application
class and configures it with the information you configure in the application configuration resource file.
Download
FAQ History |
API
Search Feedback |
All of the material in The J2EE(TM) 1.4 Tutorial is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.