EdgeExpressDB
view release on metacpan or search on metacpan
www/edgeexpress/jscript/SpryAssets/SpryData.js view on Meta::CPAN
// The root node of the resulting path tree should contain the XPath
// to the common parent. Make this the XPath we generate our initial
// set of rows from so we can group the results of flattening the other
// subPaths in predictable/expected manner.
mainXPath = commonParent.path;
subPaths = commonParent.subPaths;
// If the XPath to the common parent we calculated isn't our main XPath
// or any of the subPaths specified by the user, it is used purely for
// grouping and joining the data we will flatten. We don't want to include
// any of the columns for the rows created for the common parent XPath since
// the user did not ask for it.
suppressColumns = commonParent.xpath ? false : true;
}
rs = Spry.Utils.getRecordSetFromXMLDoc(rawDataDoc, mainXPath, suppressColumns);
if (!rs)
{
Spry.Debug.reportError("Spry.Data.XMLDataSet.loadDataIntoDataSet() failed to create dataSet '" + this.name + "'for '" + this.xpath + "' - " + this.url + "\n");
return;
}
// Now that we have our base set of rows, flatten any additional subPaths
// specified by the user.
this.flattenSubPaths(rs, subPaths);
this.doc = rs.xmlDoc;
this.data = rs.data;
this.dataHash = rs.dataHash;
this.dataWasLoaded = (this.doc != null);
};
Spry.Data.XMLDataSet.prototype.xhRequestProcessor = function(xhRequest)
{
// XMLDataSet uses the responseXML from the xhRequest
var resp = xhRequest.responseXML;
var manualParseRequired = false;
if (xhRequest.status != 200)
{
if (xhRequest.status == 0)
{
// The page that is attempting to load data was probably loaded with
// a file:// url. Mozilla based browsers will actually provide the complete DOM
// tree for the data, but IE provides an empty document node so try to parse
// the xml text manually to create a dom tree we can use.
if (xhRequest.responseText && (!resp || !resp.firstChild))
manualParseRequired = true;
}
}
else if (!resp)
{
// The server said it sent us data, but for some reason we don't have
// an XML DOM document. Some browsers won't auto-create an XML DOM
// unless the server used a content-type of "text/xml" or "application/xml".
// Try to manually parse the XML string, just in case the server
// gave us an unexpected Content-Type.
manualParseRequired = true;
}
if (manualParseRequired)
resp = Spry.Utils.stringToXMLDoc(xhRequest.responseText);
if (!resp || !resp.firstChild || resp.firstChild.nodeName == "parsererror")
return null;
return resp;
};
Spry.Data.XMLDataSet.prototype.sessionExpiredChecker = function(req)
{
if (req.xhRequest.responseText == 'session expired')
return true;
else
{
if (req.rawData)
{
var firstChild = req.rawData.documentElement.firstChild;
if (firstChild && firstChild.nodeValue == "session expired")
return true;
}
}
return false;
};
//////////////////////////////////////////////////////////////////////
//
// Spry.Data.Region
//
//////////////////////////////////////////////////////////////////////
Spry.Data.Region = function(regionNode, name, isDetailRegion, data, dataSets, regionStates, regionStateMap, hasBehaviorAttributes)
{
this.regionNode = regionNode;
this.name = name;
this.isDetailRegion = isDetailRegion;
this.data = data;
this.dataSets = dataSets;
this.hasBehaviorAttributes = hasBehaviorAttributes;
this.tokens = null;
this.currentState = null;
this.states = { ready: true };
this.stateMap = {};
Spry.Utils.setOptions(this.states, regionStates);
Spry.Utils.setOptions(this.stateMap, regionStateMap);
// Add the region as an observer to the dataSet!
for (var i = 0; i < this.dataSets.length; i++)
{
var ds = this.dataSets[i];
try
{
( run in 1.751 second using v1.01-cache-2.11-cpan-524268b4103 )