如何使错误页面(http 500)在 IceFaces 中工作?

发布于 2024-10-25 23:10:18 字数 430 浏览 0 评论 0原文

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

我可以通过使用

<f:ajax disabled="true">...</f:ajax>

但我想从 Icefaces 禁用此自动 ajax 来使其工作(请参阅问题 如何禁用未经请求的 ajax使用 Icefaces 时使用标准组件 (h:commandButton)? ),或者让错误页面正常工作。

JSF 实现是 Mojarra 2.1,它随 Glassfish 3.1 一起提供。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

郁金香雨 2024-11-01 23:10:19

基本问题是 Icefaces 捕获提交按钮并将 ajax 放入其中。我认为这只是不好的行为:我知道类似的事情可能发生在ice:commandButton中甚至在ice:form下,但它也发生在h:commandButton到h:form上。可以根据 http://wiki.icefaces.org/display/ICE/Configuration< 禁用此功能/a> ,通过在 web.xml 中将自动渲染上下文参数设置为 false 。但是,您需要在每个icefaces 表单上明确启用此行为(否则您会收到错误)。

无论如何,如下所述: http://wiki.icefaces.org/display/ICE/Handling +异常,将此脚本放在页面中基本上可以解决问题:

                //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 的正常行为是显示一个带有错误的弹出窗口,但这并没有发生。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文