IntroductionOne of the holes in JSF, in my professional judgement, is the lack of really good exception handling on the client for AJAX exceptions. A number of client frameworks like PrimeFaces, OmniFaces, and RichFaces attempt to cleanup for this shortcoming, it is still a deficiency.
The capabilities are present to make AJAX exception handling more robust. The "chemistry" is present in the framework, but it is not really standardized.
In this short example, I am demonstrating how to use the
jsf.ajax.addOnErrorfunctionality to make client exception handling better. We will display at a minimum, an alert to let them know something bad has happened to their request.
Additionally, I will demonstrate how to use XPath to get additional information from the response.
SolutionThe solution is to add the following code to the
jsf.ajax.handler.jsthat is loaded using JSF
Here are the contents of the file.