【问题标题】:how to make error page (http 500) work in IceFaces?如何使错误页面(http 500)在 IceFaces 中工作?
【发布时间】:2011-07-21 23:39:01
【问题描述】:

使用 Icefaces 2,如果在标准(=非 icefaces)h:commandButton 上执行操作方法期间发生错误,则按钮似乎没有操作。不显示错误页面,尽管在 web.xml 中配置为这样做。

我可以通过用

包围标签来使它工作
<f:ajax disabled="true">...</f:ajax>

但我想从 Icefaces 禁用这个自动 ajax(参见问题 How to disable unsollicited ajax on standard components (h:commandButton) while using Icefaces?),或者让错误页面正常工作。

JSF 实现是 Mojarra 2.1,Glassfish 3.1 附带。

【问题讨论】:

    标签: 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 行为会显示一个带有错误的弹出窗口,而这并没有发生。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-23
      • 2010-11-05
      • 2020-05-09
      • 1970-01-01
      • 2017-11-05
      相关资源
      最近更新 更多