tags:

views:

121

answers:

2

Hi,

I have just started learning about Java server faces and successfully tested out my first web app in JSF.

What puzzles me is that the navigation rules are specified in my faces-config.xml located in my WEB-INF folder and no where in my web.xml have i specified the location of my faces-config.xml file location.

So how does navigation take place ?

A: 

I believe the Faces servlet defined in web.xml loads the faces-config.xml when the web app starts up.

Kaleb Brasee
you say you believe, can't you tell me surely if that is what happens ?Does it mean that it looks for a faces-config.xml at a default location ?Can I override that default location ?
Anand
+2  A: 

The JSF 1.2 specification (JSR 252) requires any JSF implementation to automatically load /WEB-INF/faces-config.xml at startup (if such a resource exists).

Quoting the section 10.4.2 Application Startup Behavior:

At application startup time, before any requests are processed, the JSF implementation must process zero or more application configuration resources, located according to the following algorithm:

  • Search for all resources named “META-INF/faces-config.xml” in the ServletContext resource paths for this web application, and load each as a JSF configuration resource (in reverse order of the order in which they are returned by getResources() on the current Thread’s ContextClassLoader).
  • Check for the existence of a context initialization parameter named javax.faces.CONFIG_FILES. If it exists, treat it as a comma-delimited list of context relative resource paths (starting with a “/”), and load each of the specfied resources.
  • Check for the existence of a web application configuration resource named “/WEB-INF/faces-config.xml”, and load it if the resource exists.
Pascal Thivent