<html>
<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The source code</title>
<link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../resources/prettify/prettify.js"></script>
</head>
<body onload="prettyPrint();">
<pre class="prettyprint lang-js">/*!
- * Ext JS Library 3.0.3
- * Copyright(c) 2006-2009 Ext JS, LLC
+ * Ext JS Library 3.2.0
+ * Copyright(c) 2006-2010 Ext JS, Inc.
* licensing@extjs.com
* http://www.extjs.com/license
*/
Ext.data.XmlReader = function(meta, recordType){
meta = meta || {};
- // backwards compat, convert idPath to idProperty
- meta.idProperty = meta.idProperty || meta.idPath;
+ // backwards compat, convert idPath or id / success
+ Ext.applyIf(meta, {
+ idProperty: meta.idProperty || meta.idPath || meta.id,
+ successProperty: meta.successProperty || meta.success
+ });
Ext.data.XmlReader.superclass.constructor.call(this, meta, recordType || meta.fields);
};
},
/**
- * Decode a json response from server.
+ * Decode an XML response from server.
* @param {String} action [{@link Ext.data.Api#actions} create|read|update|destroy]
- * @param {Ext.data.Response} response Returns an instance of {@link Ext.data.Response}
+ * @param {Object} response HTTP Response object from browser.
+ * @return {Ext.data.Response} An instance of {@link Ext.data.Response}
*/
readResponse : function(action, response) {
var q = Ext.DomQuery,
doc = response.responseXML;
+ // create general Response instance.
var res = new Ext.data.Response({
action: action,
success : this.getSuccess(doc),
message: this.getMessage(doc),
- data: this.extractData(q.select(this.meta.record, doc) || q.select(this.meta.root, doc)),
+ data: this.extractData(q.select(this.meta.record, doc) || q.select(this.meta.root, doc), false),
raw: doc
});
throw new Ext.data.DataReader.Error('successProperty-response', this.meta.successProperty);
}
+ // Create actions from a response having status 200 must return pk
if (action === Ext.data.Api.actions.create) {
var def = Ext.isDefined(res.data);
if (def && Ext.isEmpty(res.data)) {
}
this.getRoot = function(res) {
return (!Ext.isEmpty(res[this.meta.record])) ? res[this.meta.record] : res[this.meta.root];
- }
+ };
if (s.idPath || s.idProperty) {
var g = this.createAccessor(s.idPath || s.idProperty);
this.getId = function(rec) {
case this.meta.totalProperty:
return function(root, def){
return q.selectNumber(key, root, def);
- }
+ };
break;
case this.meta.successProperty:
return function(root, def) {
var sv = q.selectValue(key, root, true);
var success = sv !== false && sv !== 'false';
return success;
- }
+ };
break;
default:
return function(root, def) {
return q.selectValue(key, root, def);
- }
+ };
break;
}
};
}(),
- /**
- * Extracts rows of record-data from server. iterates and calls #extractValues
- * TODO I don't care much for method-names of #extractData, #extractValues.
- * @param {Array} root
- * @param {Boolean} returnRecords When true, will return instances of Ext.data.Record; otherwise just hashes.
- * @private
- * @ignore
- */
- extractData : function(root, returnRecords) {
- var Record = this.recordType,
- records = [],
- f = Record.prototype.fields,
- fi = f.items,
- fl = f.length;
- if (returnRecords === true) {
- for (var i = 0, len = root.length; i < len; i++) {
- var data = root[i],
- record = new Record(this.extractValues(data, fi, fl), this.getId(data));
-
- record.node = data;
- records.push(record);
- }
- } else {
- for (var i = 0, len = root.length; i < len; i++) {
- records.push(this.extractValues(root[i], fi, fl));
- }
- }
- return records;
- },
-
/**
* extracts values and type-casts a row of data from server, extracted by #extractData
* @param {Hash} data
}
return values;
}
-});</pre>
+});</pre>
</body>
</html>
\ No newline at end of file