I have a JSF web application in JBoss 7.1 and Richfaces 4.1. I tried to configure a custom error page in web.xml but came across the problem, that this does not work for AJAX requests. As a solution I tried to use Omnifaces FullAjaxExceptionHandler which displays the error page fine.
However I wanted to add a form that allows the user to enter additional information and send this, along with the exception, as an email to me. The problem is that on the error page, the submit buttons does not work. When I click on it the error page just reloaded. On the next click everything works as expected.
The same problem occurs with h:commandlinks in a small menu that is in the template of the error page.
I’m quite new to JSF so I don’t really know why this happens and how it can be fixed. Or is there a better way to accomplish this?
This is related to JSF spec issue 790 which boils down to that ajax-updating some component which in turn contains one or more
<h:form>components doesn’t properly update the new view state identifier of those forms.This issue is fixed in the upcoming JSF 2.2, but until then you’ve to do with the following JavaScript based workaround.
Just include it as
<h:outputScript name="some.js" target="head">inside the<h:body>of the error page. If you can’t guarantee that the page uses JSF<f:ajax>, then you might want to add an additionalif (typeof jsf !== 'undefined')check beforejsf.ajax.addOnEvent()call.The JSF component library PrimeFaces has already solved this issue in its core ajax engine, so if you happen to use it already, you might want to replace all
<f:ajax>links/buttons by the PrimeFaces ones.See also: