<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
- * licensing@extjs.com
- * http://www.extjs.com/license
+ * Ext JS Library 3.3.1
+ * Copyright(c) 2006-2010 Sencha Inc.
+ * licensing@sencha.com
+ * http://www.sencha.com/license
*/
-<div id="cls-Ext.data.DirectProxy"></div>/**\r
- * @class Ext.data.DirectProxy\r
- * @extends Ext.data.DataProxy\r
- */\r
-Ext.data.DirectProxy = function(config){\r
- Ext.apply(this, config);\r
- if(typeof this.paramOrder == 'string'){\r
- this.paramOrder = this.paramOrder.split(/[\s,|]/);\r
- }\r
- Ext.data.DirectProxy.superclass.constructor.call(this, config);\r
-};\r
-\r
-Ext.extend(Ext.data.DirectProxy, Ext.data.DataProxy, {\r
- <div id="cfg-Ext.data.DirectProxy-paramOrder"></div>/**\r
- * @cfg {Array/String} paramOrder Defaults to <tt>undefined</tt>. A list of params to be executed\r
- * server side. Specify the params in the order in which they must be executed on the server-side\r
- * as either (1) an Array of String values, or (2) a String of params delimited by either whitespace,\r
- * comma, or pipe. For example,\r
- * any of the following would be acceptable:<pre><code>\r
-paramOrder: ['param1','param2','param3']\r
-paramOrder: 'param1 param2 param3'\r
-paramOrder: 'param1,param2,param3'\r
-paramOrder: 'param1|param2|param'\r
- </code></pre>\r
- */\r
- paramOrder: undefined,\r
-\r
- <div id="cfg-Ext.data.DirectProxy-paramsAsHash"></div>/**\r
- * @cfg {Boolean} paramsAsHash\r
- * Send parameters as a collection of named arguments (defaults to <tt>true</tt>). Providing a\r
- * <tt>{@link #paramOrder}</tt> nullifies this configuration.\r
- */\r
- paramsAsHash: true,\r
-\r
- <div id="cfg-Ext.data.DirectProxy-directFn"></div>/**\r
- * @cfg {Function} directFn\r
- * Function to call when executing a request. directFn is a simple alternative to defining the api configuration-parameter\r
- * for Store's which will not implement a full CRUD api.\r
- */\r
- directFn : undefined,\r
-\r
- // protected\r
- doRequest : function(action, rs, params, reader, callback, scope, options) {\r
- var args = [];\r
- var directFn = this.api[action] || this.directFn;\r
-\r
- switch (action) {\r
- case Ext.data.Api.actions.create:\r
- args.push(params.jsonData[reader.meta.root]); // <-- create(Hash)\r
- break;\r
- case Ext.data.Api.actions.read:\r
- // If the method has no parameters, ignore the paramOrder/paramsAsHash.\r
- if(directFn.directCfg.method.len > 0){\r
- if(this.paramOrder){\r
- for(var i = 0, len = this.paramOrder.length; i < len; i++){\r
- args.push(params[this.paramOrder[i]]);\r
- }\r
- }else if(this.paramsAsHash){\r
- args.push(params);\r
- }\r
- }\r
- break;\r
- case Ext.data.Api.actions.update:\r
- args.push(params.jsonData[reader.meta.root]); // <-- update(Hash/Hash[])\r
- break;\r
- case Ext.data.Api.actions.destroy:\r
- args.push(params.jsonData[reader.meta.root]); // <-- destroy(Int/Int[])\r
- break;\r
- }\r
-\r
- var trans = {\r
- params : params || {},\r
- request: {\r
- callback : callback,\r
- scope : scope,\r
- arg : options\r
- },\r
- reader: reader\r
- };\r
-\r
- args.push(this.createCallback(action, rs, trans), this);\r
- directFn.apply(window, args);\r
- },\r
-\r
- // private\r
- createCallback : function(action, rs, trans) {\r
- return function(result, res) {\r
- if (!res.status) {\r
- // @deprecated fire loadexception\r
- if (action === Ext.data.Api.actions.read) {\r
- this.fireEvent("loadexception", this, trans, res, null);\r
- }\r
- this.fireEvent('exception', this, 'remote', action, trans, res, null);\r
- trans.request.callback.call(trans.request.scope, null, trans.request.arg, false);\r
- return;\r
- }\r
- if (action === Ext.data.Api.actions.read) {\r
- this.onRead(action, trans, result, res);\r
- } else {\r
- this.onWrite(action, trans, result, res, rs);\r
- }\r
- };\r
- },\r
- /**\r
- * Callback for read actions\r
- * @param {String} action [Ext.data.Api.actions.create|read|update|destroy]\r
- * @param {Object} trans The request transaction object\r
- * @param {Object} res The server response\r
- * @private\r
- */\r
- onRead : function(action, trans, result, res) {\r
- var records;\r
- try {\r
- records = trans.reader.readRecords(result);\r
- }\r
- catch (ex) {\r
- // @deprecated: Fire old loadexception for backwards-compat.\r
- this.fireEvent("loadexception", this, trans, res, ex);\r
-\r
- this.fireEvent('exception', this, 'response', action, trans, res, ex);\r
- trans.request.callback.call(trans.request.scope, null, trans.request.arg, false);\r
- return;\r
- }\r
- this.fireEvent("load", this, res, trans.request.arg);\r
- trans.request.callback.call(trans.request.scope, records, trans.request.arg, true);\r
- },\r
- /**\r
- * Callback for write actions\r
- * @param {String} action [Ext.data.Api.actions.create|read|update|destroy]\r
- * @param {Object} trans The request transaction object\r
- * @param {Object} res The server response\r
- * @private\r
- */\r
- onWrite : function(action, trans, result, res, rs) {\r
- var data = trans.reader.extractData(result);\r
- this.fireEvent("write", this, action, data, res, rs, trans.request.arg);\r
- trans.request.callback.call(trans.request.scope, data, res, true);\r
- }\r
-});\r
-\r
-</pre>
+<div id="cls-Ext.data.DirectProxy"></div>/**
+ * @class Ext.data.DirectProxy
+ * @extends Ext.data.DataProxy
+ */
+Ext.data.DirectProxy = function(config){
+ Ext.apply(this, config);
+ if(typeof this.paramOrder == 'string'){
+ this.paramOrder = this.paramOrder.split(/[\s,|]/);
+ }
+ Ext.data.DirectProxy.superclass.constructor.call(this, config);
+};
+
+Ext.extend(Ext.data.DirectProxy, Ext.data.DataProxy, {
+ <div id="cfg-Ext.data.DirectProxy-paramOrder"></div>/**
+ * @cfg {Array/String} paramOrder Defaults to <tt>undefined</tt>. A list of params to be executed
+ * server side. Specify the params in the order in which they must be executed on the server-side
+ * as either (1) an Array of String values, or (2) a String of params delimited by either whitespace,
+ * comma, or pipe. For example,
+ * any of the following would be acceptable:<pre><code>
+paramOrder: ['param1','param2','param3']
+paramOrder: 'param1 param2 param3'
+paramOrder: 'param1,param2,param3'
+paramOrder: 'param1|param2|param'
+ </code></pre>
+ */
+ paramOrder: undefined,
+
+ <div id="cfg-Ext.data.DirectProxy-paramsAsHash"></div>/**
+ * @cfg {Boolean} paramsAsHash
+ * Send parameters as a collection of named arguments (defaults to <tt>true</tt>). Providing a
+ * <tt>{@link #paramOrder}</tt> nullifies this configuration.
+ */
+ paramsAsHash: true,
+
+ <div id="cfg-Ext.data.DirectProxy-directFn"></div>/**
+ * @cfg {Function} directFn
+ * Function to call when executing a request. directFn is a simple alternative to defining the api configuration-parameter
+ * for Store's which will not implement a full CRUD api.
+ */
+ directFn : undefined,
+
+ <div id="method-Ext.data.DirectProxy-doRequest"></div>/**
+ * DirectProxy implementation of {@link Ext.data.DataProxy#doRequest}
+ * @param {String} action The crud action type (create, read, update, destroy)
+ * @param {Ext.data.Record/Ext.data.Record[]} rs If action is load, rs will be null
+ * @param {Object} params An object containing properties which are to be used as HTTP parameters
+ * for the request to the remote server.
+ * @param {Ext.data.DataReader} reader The Reader object which converts the data
+ * object into a block of Ext.data.Records.
+ * @param {Function} callback
+ * <div class="sub-desc"><p>A function to be called after the request.
+ * The <tt>callback</tt> is passed the following arguments:<ul>
+ * <li><tt>r</tt> : Ext.data.Record[] The block of Ext.data.Records.</li>
+ * <li><tt>options</tt>: Options object from the action request</li>
+ * <li><tt>success</tt>: Boolean success indicator</li></ul></p></div>
+ * @param {Object} scope The scope (<code>this</code> reference) in which the callback function is executed. Defaults to the browser window.
+ * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
+ * @protected
+ */
+ doRequest : function(action, rs, params, reader, callback, scope, options) {
+ var args = [],
+ directFn = this.api[action] || this.directFn;
+
+ switch (action) {
+ case Ext.data.Api.actions.create:
+ args.push(params.jsonData); // <-- create(Hash)
+ break;
+ case Ext.data.Api.actions.read:
+ // If the method has no parameters, ignore the paramOrder/paramsAsHash.
+ if(directFn.directCfg.method.len > 0){
+ if(this.paramOrder){
+ for(var i = 0, len = this.paramOrder.length; i < len; i++){
+ args.push(params[this.paramOrder[i]]);
+ }
+ }else if(this.paramsAsHash){
+ args.push(params);
+ }
+ }
+ break;
+ case Ext.data.Api.actions.update:
+ args.push(params.jsonData); // <-- update(Hash/Hash[])
+ break;
+ case Ext.data.Api.actions.destroy:
+ args.push(params.jsonData); // <-- destroy(Int/Int[])
+ break;
+ }
+
+ var trans = {
+ params : params || {},
+ request: {
+ callback : callback,
+ scope : scope,
+ arg : options
+ },
+ reader: reader
+ };
+
+ args.push(this.createCallback(action, rs, trans), this);
+ directFn.apply(window, args);
+ },
+
+ // private
+ createCallback : function(action, rs, trans) {
+ var me = this;
+ return function(result, res) {
+ if (!res.status) {
+ // @deprecated fire loadexception
+ if (action === Ext.data.Api.actions.read) {
+ me.fireEvent("loadexception", me, trans, res, null);
+ }
+ me.fireEvent('exception', me, 'remote', action, trans, res, null);
+ trans.request.callback.call(trans.request.scope, null, trans.request.arg, false);
+ return;
+ }
+ if (action === Ext.data.Api.actions.read) {
+ me.onRead(action, trans, result, res);
+ } else {
+ me.onWrite(action, trans, result, res, rs);
+ }
+ };
+ },
+
+ <div id="method-Ext.data.DirectProxy-onRead"></div>/**
+ * Callback for read actions
+ * @param {String} action [Ext.data.Api.actions.create|read|update|destroy]
+ * @param {Object} trans The request transaction object
+ * @param {Object} result Data object picked out of the server-response.
+ * @param {Object} res The server response
+ * @protected
+ */
+ onRead : function(action, trans, result, res) {
+ var records;
+ try {
+ records = trans.reader.readRecords(result);
+ }
+ catch (ex) {
+ // @deprecated: Fire old loadexception for backwards-compat.
+ this.fireEvent("loadexception", this, trans, res, ex);
+
+ this.fireEvent('exception', this, 'response', action, trans, res, ex);
+ trans.request.callback.call(trans.request.scope, null, trans.request.arg, false);
+ return;
+ }
+ this.fireEvent("load", this, res, trans.request.arg);
+ trans.request.callback.call(trans.request.scope, records, trans.request.arg, true);
+ },
+ <div id="method-Ext.data.DirectProxy-onWrite"></div>/**
+ * Callback for write actions
+ * @param {String} action [{@link Ext.data.Api#actions create|read|update|destroy}]
+ * @param {Object} trans The request transaction object
+ * @param {Object} result Data object picked out of the server-response.
+ * @param {Object} res The server response
+ * @param {Ext.data.Record/[Ext.data.Record]} rs The Store resultset associated with the action.
+ * @protected
+ */
+ onWrite : function(action, trans, result, res, rs) {
+ var data = trans.reader.extractData(trans.reader.getRoot(result), false);
+ var success = trans.reader.getSuccess(result);
+ success = (success !== false);
+ if (success){
+ this.fireEvent("write", this, action, data, res, rs, trans.request.arg);
+ }else{
+ this.fireEvent('exception', this, 'remote', action, trans, result, rs);
+ }
+ trans.request.callback.call(trans.request.scope, data, res, success);
+ }
+});
+</pre>
</body>
</html>
\ No newline at end of file