X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/25ef3491bd9ae007ff1fc2b0d7943e6eaaccf775..ddde20c4d4ac6a8d53de079761155de813845b3c:/docs/source/XmlReader.html diff --git a/docs/source/XmlReader.html b/docs/source/XmlReader.html index 41affb95..6413a2d2 100644 --- a/docs/source/XmlReader.html +++ b/docs/source/XmlReader.html @@ -1,13 +1,14 @@
+/*! - * 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 */ @@ -66,8 +67,11 @@ var myReader = new Ext.data.XmlReader({ 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); }; @@ -123,19 +127,21 @@ Ext.extend(Ext.data.XmlReader, Ext.data.DataReader, { }, /** - * 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 }); @@ -143,6 +149,7 @@ Ext.extend(Ext.data.XmlReader, Ext.data.DataReader, { 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)) { @@ -185,7 +192,7 @@ Ext.extend(Ext.data.XmlReader, Ext.data.DataReader, { } 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) { @@ -218,54 +225,24 @@ Ext.extend(Ext.data.XmlReader, Ext.data.DataReader, { 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 @@ -283,6 +260,6 @@ Ext.extend(Ext.data.XmlReader, Ext.data.DataReader, { } return values; } -});+}); \ No newline at end of file