/*!
- * Ext JS Library 3.0.0
+ * Ext JS Library 3.0.3
* Copyright(c) 2006-2009 Ext JS, LLC
* licensing@extjs.com
* http://www.extjs.com/license
*/\r
this.recordType = Ext.isArray(recordType) ?\r
Ext.data.Record.create(recordType) : recordType;\r
+
+ // if recordType defined make sure extraction functions are defined\r
+ if (this.recordType){\r
+ this.buildExtractors();\r
+ }
};\r
\r
Ext.data.DataReader.prototype = {\r
-\r
/**\r
- * Abstract method, overridden in {@link Ext.data.JsonReader}\r
+ * @cfg {String} messageProperty [undefined] Optional name of a property within a server-response that represents a user-feedback message.\r
+ */\r
+ /**\r
+ * Abstract method created in extension's buildExtractors impl.\r
+ */\r
+ getTotal: Ext.emptyFn,\r
+ /**\r
+ * Abstract method created in extension's buildExtractors impl.\r
+ */\r
+ getRoot: Ext.emptyFn,\r
+ /**\r
+ * Abstract method created in extension's buildExtractors impl.\r
+ */\r
+ getMessage: Ext.emptyFn,\r
+ /**\r
+ * Abstract method created in extension's buildExtractors impl.\r
+ */\r
+ getSuccess: Ext.emptyFn,\r
+ /**\r
+ * Abstract method created in extension's buildExtractors impl.\r
+ */\r
+ getId: Ext.emptyFn,\r
+ /**\r
+ * Abstract method, overridden in DataReader extensions such as {@link Ext.data.JsonReader} and {@link Ext.data.XmlReader}\r
*/\r
buildExtractors : Ext.emptyFn,\r
+ /**\r
+ * Abstract method overridden in DataReader extensions such as {@link Ext.data.JsonReader} and {@link Ext.data.XmlReader}\r
+ */\r
+ extractData : Ext.emptyFn,\r
+ /**\r
+ * Abstract method overridden in DataReader extensions such as {@link Ext.data.JsonReader} and {@link Ext.data.XmlReader}\r
+ */\r
+ extractValues : Ext.emptyFn,\r
\r
/**\r
* Used for un-phantoming a record after a successful database insert. Sets the records pk along with new data from server.\r
//rs.commit();\r
throw new Ext.data.DataReader.Error('realize', rs);\r
}\r
- this.buildExtractors();\r
- var values = this.extractValues(data, rs.fields.items, rs.fields.items.length);\r
rs.phantom = false; // <-- That's what it's all about\r
rs._phid = rs.id; // <-- copy phantom-id -> _phid, so we can remap in Store#onCreateRecords\r
- rs.id = data[this.meta.idProperty];\r
- rs.data = values;\r
+ rs.id = this.getId(data);\r
+ rs.data = data;\r
rs.commit();\r
}\r
},\r
\r
/**\r
* Used for updating a non-phantom or "real" record's data with fresh data from server after remote-save.\r
- * You <b>must</b> return a complete new record from the server. If you don't, your local record's missing fields\r
- * will be populated with the default values specified in your Ext.data.Record.create specification. Without a defaultValue,\r
- * local fields will be populated with empty string "". So return your entire record's data after both remote create and update.\r
- * In addition, you <b>must</b> return record-data from the server in the same order received.\r
- * Will perform a commit as well, un-marking dirty-fields. Store's "update" event will be suppressed as the record receives\r
- * a fresh new data-hash.\r
+ * If returning data from multiple-records after a batch-update, you <b>must</b> return record-data from the server in\r
+ * the same order received. Will perform a commit as well, un-marking dirty-fields. Store's "update" event will be\r
+ * suppressed as the record receives fresh new data-hash\r
* @param {Record/Record[]} rs\r
* @param {Object/Object[]} data\r
*/\r
}\r
}\r
else {\r
- // If rs is NOT an array but data IS, see if data contains just 1 record. If so extract it and carry on.\r
+ // If rs is NOT an array but data IS, see if data contains just 1 record. If so extract it and carry on.\r
if (Ext.isArray(data) && data.length == 1) {\r
data = data.shift();\r
}\r
- if (!this.isData(data)) {\r
- // TODO: create custom Exception class to return record in thrown exception. Allow exception-handler the choice\r
- // to commit or not rather than blindly rs.commit() here.\r
- rs.commit();\r
- throw new Ext.data.DataReader.Error('update', rs);\r
+ if (this.isData(data)) {\r
+ rs.data = Ext.apply(rs.data, data);\r
}\r
- this.buildExtractors();\r
- rs.data = this.extractValues(Ext.apply(rs.data, data), rs.fields.items, rs.fields.items.length);\r
rs.commit();\r
}\r
},\r
* @return {Boolean}\r
*/\r
isData : function(data) {\r
- return (data && Ext.isObject(data) && !Ext.isEmpty(data[this.meta.idProperty])) ? true : false;\r
+ return (data && Ext.isObject(data) && !Ext.isEmpty(this.getId(data))) ? true : false;\r
+ },\r
+\r
+ // private function a store will createSequence upon\r
+ onMetaChange : function(meta){\r
+ delete this.ef;\r
+ this.meta = meta;\r
+ this.recordType = Ext.data.Record.create(meta.fields);\r
+ this.buildExtractors();\r
}\r
};\r
\r
});\r
\r
\r
+/**\r
+ * Ext.data.Response\r
+ * A generic response class to normalize response-handling internally to the framework.\r
+ * TODO move to own file, add to jsb.\r
+ */\r
+Ext.data.Response = function(params) {\r
+ Ext.apply(this, params);\r
+};\r
+Ext.data.Response.prototype = {\r
+ /**\r
+ * @property {String} action {@link Ext.data.Api#actions}\r
+ */\r
+ action: undefined,\r
+ /**\r
+ * @property {Boolean} success\r
+ */\r
+ success : undefined,\r
+ /**\r
+ * @property {String} message\r
+ */\r
+ message : undefined,\r
+ /**\r
+ * @property {Array/Object} data\r
+ */\r
+ data: undefined,\r
+ /**\r
+ * @property {Object} raw The raw response returned from server-code\r
+ */\r
+ raw: undefined,\r
+ /**\r
+ * @property {Ext.data.Record/Ext.data.Record[]} record(s) related to the Request action\r
+ */\r
+ records: undefined\r
+}\r