使用 Icefaces 2,如果在标准(=非icefaces)h:commandButton 上执行操作方法期间发生错误,则该按钮似乎没有任何操作。尽管在 web.xml 中将其配置为显示错误页面,但不会显示错误页面。
我可以通过将标签包围来使其工作
<f:ajax disabled="true">...</f:ajax>
但我想从 Icefaces 禁用这个自动 ajax (参见问题使用 Icefaces 时如何禁用标准组件 (h:commandButton) 上未经请求的 ajax? https://stackoverflow.com/questions/5407711),或者让错误页面正常工作。
JSF 实现是 Mojarra 2.1,它随 Glassfish 3.1 一起提供。
基本问题是 Icefaces 捕获提交按钮并将 ajax 放入其中。我认为这只是不好的行为:我知道类似的事情可能发生在ice:commandButton中甚至在ice:form下,但它也发生在h:commandButton到h:form上。可以禁用此功能,按照http://wiki.icefaces.org/display/ICE/Configuration http://wiki.icefaces.org/display/ICE/Configuration,通过在 web.xml 中将 autorender 上下文参数设置为 false 。但是,您需要在每个icefaces表单上明确启用此行为(否则您会收到错误)。
无论如何,正如这里所述:http://wiki.icefaces.org/display/ICE/Handling+Exceptions 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 http://jira.icefaces.org/browse/ICE-6546。我知道 Icefaces 的正常行为是显示一个带有错误的弹出窗口,但这并没有发生。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)