问题
Using Icefaces 2, if an error occurs during execution of an action method on a standard (=not icefaces) h:commandButton, it just seems the button has no action. No error page is displayed, although it is configured to do so in web.xml.
I can make it work by surrounding the tag with
<f:ajax disabled="true">...</f:ajax>
But I'd want to either disable this automatic ajax from Icefaces (see question How to disable unsollicited ajax on standard components (h:commandButton) while using Icefaces? ), or make the error page work anyway.
JSF implementation is Mojarra 2.1 which comes with Glassfish 3.1.
回答1:
The basic problem is that Icefaces captures the submit button and puts ajax in it. I think this is simply bad behavior: I understand that something like that could happen in a ice:commandButton or even under ice:form, but it happens to h:commandButton to h:form as well. This can be disabled, as per http://wiki.icefaces.org/display/ICE/Configuration , by setting autorender context parameter to false in web.xml . But then, you need to explicitely enable this behavior on every icefaces form (you get an error otherwise).
Anyway, as stated here: http://wiki.icefaces.org/display/ICE/Handling+Exceptions, putting this script in the page basically solves the problem:
//Assign your error handling function to a variable
var iceErrorCallback = function iceHandleError(statusCode, responseTxt, responseDOM) {
//Handle all errors by simply redirecting to an error page
window.location.href = "./generalError.xhtml";
}
//Safely check if ICEfaces is available
if (ice) {
//Turn off the popups as we plan to handle this ourselves
ice.configuration.disableDefaultIndicators = true;
//Register your error handler as a callback
ice.onServerError(iceErrorCallback);
}
Update: I had to patch some Icefaces javascript for it to work, see http://jira.icefaces.org/browse/ICE-6546 . I know realize normal Icefaces behavior is displaying a popup with the error, which didn't happen.
来源:https://stackoverflow.com/questions/5417085/how-to-make-error-page-http-500-work-in-icefaces