【问题标题】:how to make error page (http 500) work in IceFaces?如何使错误页面(http 500)在 IceFaces 中工作?
【发布时间】:2011-07-21 23:39:01
【问题描述】:
【问题讨论】:
标签:
java
ajax
jsf
jsf-2
icefaces
【解决方案1】:
基本问题是 Icefaces 捕获提交按钮并将 ajax 放入其中。我认为这只是不好的行为:我知道类似的事情可能发生在 ice:commandButton 甚至是 ice:form 下,但它也会发生在 h:commandButton 到 h:form 中。根据http://wiki.icefaces.org/display/ICE/Configuration,可以通过在 web.xml 中将 autorender 上下文参数设置为 false 来禁用此功能。但是,您需要在每个 icefaces 表单上显式启用此行为(否则会出现错误)。
反正这里说的:http://wiki.icefaces.org/display/ICE/Handling+Exceptions,把这个脚本放到页面里基本就解决了:
//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);
}
更新:我必须修补一些 Icefaces javascript 才能使其工作,请参阅 http://jira.icefaces.org/browse/ICE-6546 。我知道正常的 Icefaces 行为会显示一个带有错误的弹出窗口,而这并没有发生。