Adding Error Function to XPages Partial Update (dojo.xhrPost) Events?

I have a page that depends on the number of partial updates to interact with. I do not want to use the keep session alive mechanism, but I would like to track the error responses to my partial updates, warn the user that their session has expired / they need to be updated, execute the window. location.reload as soon as they confirmed the warning. In particular, in order to be triggered by user events, an attempt to partially update (and, in essence, exclusively through CSJS).

I know using Chrome DevTools that a partial update is displayed as a send request that returns a partial (update area) html plus any necessary CSJS. I also know that, as described in Dojo 1.6 with respect to dojo.xhr ( Post and Get ), it supports an error handling parameter with which I can pass the function I want to create. Currently I don’t know how to add this function into my dojo.xhrPost requests.

Seeing this XSnippet, "Preventing Caching for Dojo xhr Requests," which allows you to add the preventCache option to dojo. xhr asks, I believe this is the right approach. Again, this is an implementation that I'm not sure about. I was disappointed that the link to which he referred as a source is http://www.juliusbuss.de/web/youatnotes/blog-jb.nsf/dx/a-big-issue-for-mobile-web-apps -with-xpages-for-iphone-and-ipad-and-how-to-solve-it..htm did not work for me.

  • I'm not sure if I can use the same argument, arguments [1], as in the reference XSnippet (or which is the best position for the arguments).
  • Also, I'm not 100% sure if I need to specify this for Dojo xhrPost events, or if dojo.xhr is enough.

Would love a more experienced look.

+3
1

, partialRefresh:

// hijack the dojo function if required
if( !dojo._xhr )
    dojo._xhr = dojo.xhr;

var _error;

dojo.xhr = function(){       
    try{
        var args = arguments[1];  
        _error = args["error"]; // save the original error function

        // add your own method
        args["error"] = function(arg1, arg2){
            alert( "Hello World!" );
            _error(arg1, arg2);
        }
        arguments[1] = args;
    }catch(e){}
    dojo._xhr( arguments[0], arguments[1], arguments[2] );
}
+5

All Articles