Tuesday, December 6, 2011

responseXML

I have a nifty xml builder that diligently sends me nicelyformatted errors if a ''trappable'' one occurs on the server. Since Ibind my datasets with a specific xpath expression I cannot get tothese messages when I receive one. I would like to be able toexamine the responseXML in the onPostLoad event to deal with thesemessages. Any advice would be appreciated.responseXML
Hi got2code,

We currently don't have a hook for developers to be notifiedimmediately after the data is loaded, and before it is flattenedinto a data set using the XPath. I've been meaning to add one, soI'll make sure we have one for the 1.5 release.

Until then, you can add your own hook by adding a notficationthe Spry.Data.XMLDataSet.prototype.onRequestResponse() method. In1.4 it looks like this:

Spry.Data.XMLDataSet.prototype.onRequestResponse =function(cachedRequest, req)
{
this.setDataFromDoc(cachedRequest.doc);
};

But you can add your own hook like this:

Spry.Data.XMLDataSet.prototype.onRequestResponse =function(cachedRequest, req)
{
var notificationData = { xmlStr: req.xhRequest.responseText,xmlDoc: cachedRequest.doc };
this.notifyObservers(''onDataLoaded'', notificationData);
this.setDataFromDoc(notificationData.xmlDoc);
};

and then you can add an observer to your data set like this:

ds1.addObserver(myObserverFunc);

...

function myObserverFunc(notificationType, notifier, data)
{
if (notificaitonType != ''onDataLoaded'')
return;

// You can now access the xml string or DOM document via:
//
// data.xmlStr or data.xmlDoc.
//
// Then adjust the XPath as necessary, or report your error.
}

--== Kin ==--
  • how do ex smokers deal with
  • No comments:

    Post a Comment