After the JSF 2 big support for annotations, I'm wondering what I would use the faces-config.xml
for. What is its importance now?
In other words, what are the configurations that can only be done through faces-config.xml
and not via annotations?
Right now all what I am using it for is to declare Spring's EL resolver.
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
<application>
<el-resolver>
org.springframework.web.jsf.el.SpringBeanFacesELResolver
</el-resolver>
</application>
</faces-config>
It's still to be used for many things which can't be annotated. E.g. custom JSF validation messages:
A global i18n bundle (so that you don't need to declare
<f:loadBundle>
in every view):Explicitly supported i18n locales (so that the not-declared ones will be ignored even though there's a message bundle or resource bundle for it):
Custom view handlers:
Phase listeners (there's still no annotation for that):
Managed beans which can't be annotated (the below one gives current
Date
on#{now}
):Custom factories, such as custom exception handler factory (it also allows factories for
FacesContext
,ExternalContext
,LifeCycle
and many more so that you can provide your custom implementation):To name only the commonly used ones. If you have
faces-config.xml
tag autocompletion in your IDE, you can find them all out. Only the managed beans, validators, converters, components, renderers and point-to-point navigation cases are not needed anymore thanks to the new annotations and implicit navigation.