如何报告或显示来自 XSP.partialRefreshPost 调用的错误 [英] How can you report or display an error from an XSP.partialRefreshPost call

查看:16
本文介绍了如何报告或显示来自 XSP.partialRefreshPost 调用的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序的许多部分使用自定义事件处理程序.Tim Tripcony 在他的博客中描述了这一点......他很可能会(希望)回答这个...

I am using custom event handlers for many parts of our application. Tim Tripcony describes this in his blog... He will, most likely (hopefully) answer this...

我的代码中的事件处理程序如下所示:

The event handlers in my code look like this:

    <xp:eventHandler
        id="newbsDoSomething"
        submit="true"
        event="calledbyid"
        refreshMode="complete">
        <xp:this.action>
            <![CDATA[#{javascript:doSomethingFromSomewhere();}]]>
        </xp:this.action>
    </xp:eventHandler>

按钮或其他控件使用如下代码执行这些事件:

The buttons or other controls execute these events with code that look like this:

XSP.partialRefreshPost(("#{id:newbsDoSomething}", {
    params : {
        '$$xspsubmitvalue' : 'something that tells it what to do.'
    },
    onError : function(err) {
            alert('Whatever this method is doing got an error...');
            //I want to report the error here
    },
    onComplete : function() {
        // maybe do something else
    })
});

当我犯了一个错误(一次在一个蓝色的月亮)并且对 AJAX 请求的响应包含一个堆栈跟踪时.我想放置一个按钮,可选择在另一个页面中呈现堆栈跟踪.

When I make a mistake (once in a blue moon) and the response to the AJAX request contains a stack trace. I want to put up a button that optionally renders the stack trace in another page.

在 onError 方法中,err 是未定义的,因此没有帮助.我没有看到包含响应的 XSP 对象的属性.我可以在 Firebug 控制台中看到响应,但如何以务实的方式获得响应?

In the onError method the err is undefined, so that is not helping. I do not see a property of the XSP object that would contain the response. I can see the response in the Firebug console, but how would I get it pragmatically?

/纽布斯

推荐答案

问题是CSJS函数XSP._partialRefresh检查onError-parameter 是不是函数.如果它是一个函数,则在不带所需参数的情况下调用它.

The problem is that the CSJS function XSP._partialRefresh checks if the onError-parameter is a function or not. if it is a function, it is called w/o the required parameters.

但是如果你使用一个字符串,一个 eval 就用它完成了,所以可以做这样的事情:

But if you use a string instead, a eval is done with it, so it would be possible to do something like this:

function myErrHandler(){
    // just do some debugging
    // of ioArgs object 
    var arg = arguments[1];
    var txt = "";
    for( p in arg ){
        txt += p + " -> " + arg[p] + " [" + typeof( arg[p] ) + "]\n";
    }
    alert( txt );
}

XSP.partialRefreshPost("#{id:newbsDoSomething}", {
    onError : 'myErrHandler( arguments[0], arguments[1] )'
});

希望能帮到你

斯文

这篇关于如何报告或显示来自 XSP.partialRefreshPost 调用的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆