HTML and CSS Reference
In-Depth Information
public CustomExceptionHandlerFactory(ExceptionHandlerFactory parent) {
this.parent = parent;
}
@Override
public ExceptionHandler getExceptionHandler() {
ExceptionHandler result = new CustomExceptionHandler(parent.getExceptionHandler());
return result;
}
}
Finally, we need to register the custom exception handler factory class in the faces -config.xml , as shown in
Listing 2-40.
Listing 2-40. Registering the Custom Exception Handler Factory Class in the JSF Configuration File
<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="2.1"
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_1.xsd " >
<factory>
<exception-handler-factory>
com.jsfprohtml5.firstapplication.exceptions.MyExceptionHandlerFactory
</exception-handler-factory>
</factory>
<!-- ... -->
</faces-config>
After setting up this exception handling mechanism in the firstApplication , if an exception is thrown from the
firstApplication for whatever reason, the error.xhtml page will be displayed as Figure 2-5 .
Figure 2-5. The error handling page (error.xhtml)
the complete source code of the updated firstApplication example is available on the topic web site at
www.apress.com/9781430250104 (attached in the Chapter 2 source code zip file).
Note
Summary
In this chapter, you learned in detail the different ways for declaring, initializing, and managing the dependencies of
the JSF managed beans. You also learned in detail how to make use of the EL in your JSF applications. You now also
know in detail how to efficiently use the JSF navigation system and finally how to utilize the JSF exception handling
mechanism in order to empower your JSF application error handling.
 
 
Search WWH ::




Custom Search