Faces-config.xml? ... We don't need no stinkin' faces-config.xml!
Tuesday Mar 03, 2009
The new feature set of JSF 2.0 makes the life of the faces application developer much easier.
First, annotations. I'm sure some of you have already read up on the annotations added in 2.0, so I'll only touch on them briefly here.
- ManagedBean (this includes ManagedProperty and the scope annotations)
- FacesConverter
- FacesValidator
- FacesComponent
- FacesRenderer
- ResourceDependency
- ResourceDependencies
- FacesBehavior
- ListenerFor
- ListenersFor
The other common complaint with the faces-config.xml has been with navigation rules. To ease the pain there, we've added implict navigation.
Let's start with a simple example of this feature:
<h:commandButton value="Click" action="nextPage"/>
Give the above, if there is no explicit rule defined in the faces-config.xml for the nextPage outcome, the default JSF 2.0 navigation handler will try to match a view on disk (i.e. nextPage.xhtml). If found, it will navigate the user to that view. Note that you could specify nextPage or nextPage.xhtml.
What if you want the navigation to trigger a redirect? This can be handled as well. Building off the example above...
<h:commandButton value="Click" action="nextPage?faces-redirect=true" />
If the faces-redirect parameter is present and the value is true, the navigation will result in a client redirect.
So, with the annotations and the implicit navigation, it is possible to write an application without needing a faces-config.xml, but there are still cases where the configuration file is needed.
For example, localization information such as the default and supported locales, or using any of the advanced features such as ELResolvers, PhaseListeners, or any artifact that can rely on the decorator pattern (such as application factories, Application, RenderKit, etc).
Feel free to give these features a go and don't hesitate to provide feedback on the forums or our issue tracker.












JSF 2.0 is truly a very good initiative.
...This is great news. I can't wait to finally (mostl...
We're re-evaluating the release schedule. As soon...
WHAT A GREAT THING...
I REALLY HATE CONF...
Nice features, but, about navigation, I think that...
Great improvements!
This is good improvement.
But I would like to se...