3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js"><div id="cls-Ext.data.DirectProxy"></div>/**
\r
9 * @class Ext.data.DirectProxy
\r
10 * @extends Ext.data.DataProxy
\r
12 Ext.data.DirectProxy = function(config){
\r
13 Ext.apply(this, config);
\r
14 if(typeof this.paramOrder == 'string'){
\r
15 this.paramOrder = this.paramOrder.split(/[\s,|]/);
\r
17 Ext.data.DirectProxy.superclass.constructor.call(this, config);
\r
20 Ext.extend(Ext.data.DirectProxy, Ext.data.DataProxy, {
\r
21 <div id="cfg-Ext.data.DirectProxy-paramOrder"></div>/**
\r
22 * @cfg {Array/String} paramOrder Defaults to <tt>undefined</tt>. A list of params to be executed
\r
23 * server side. Specify the params in the order in which they must be executed on the server-side
\r
24 * as either (1) an Array of String values, or (2) a String of params delimited by either whitespace,
\r
25 * comma, or pipe. For example,
\r
26 * any of the following would be acceptable:<pre><code>
\r
27 paramOrder: ['param1','param2','param3']
\r
28 paramOrder: 'param1 param2 param3'
\r
29 paramOrder: 'param1,param2,param3'
\r
30 paramOrder: 'param1|param2|param'
\r
33 paramOrder: undefined,
\r
35 <div id="cfg-Ext.data.DirectProxy-paramsAsHash"></div>/**
\r
36 * @cfg {Boolean} paramsAsHash
\r
37 * Send parameters as a collection of named arguments (defaults to <tt>true</tt>). Providing a
\r
38 * <tt>{@link #paramOrder}</tt> nullifies this configuration.
\r
42 <div id="cfg-Ext.data.DirectProxy-directFn"></div>/**
\r
43 * @cfg {Function} directFn
\r
44 * Function to call when executing a request. directFn is a simple alternative to defining the api configuration-parameter
\r
45 * for Store's which will not implement a full CRUD api.
\r
47 directFn : undefined,
\r
50 doRequest : function(action, rs, params, reader, callback, scope, options) {
\r
52 var directFn = this.api[action] || this.directFn;
\r
55 case Ext.data.Api.actions.create:
\r
56 args.push(params[reader.meta.root]); // <-- create(Hash)
\r
58 case Ext.data.Api.actions.read:
\r
59 if(this.paramOrder){
\r
60 for(var i = 0, len = this.paramOrder.length; i < len; i++){
\r
61 args.push(params[this.paramOrder[i]]);
\r
63 }else if(this.paramsAsHash){
\r
67 case Ext.data.Api.actions.update:
\r
68 args.push(params[reader.meta.idProperty]); // <-- save(Integer/Integer[], Hash/Hash[])
\r
69 args.push(params[reader.meta.root]);
\r
71 case Ext.data.Api.actions.destroy:
\r
72 args.push(params[reader.meta.root]); // <-- destroy(Int/Int[])
\r
77 params : params || {},
\r
79 callback : callback,
\r
86 args.push(this.createCallback(action, rs, trans), this);
\r
87 directFn.apply(window, args);
\r
91 createCallback : function(action, rs, trans) {
\r
92 return function(result, res) {
\r
94 // @deprecated fire loadexception
\r
95 if (action === Ext.data.Api.actions.read) {
\r
96 this.fireEvent("loadexception", this, trans, res, null);
\r
98 this.fireEvent('exception', this, 'remote', action, trans, res, null);
\r
99 trans.request.callback.call(trans.request.scope, null, trans.request.arg, false);
\r
102 if (action === Ext.data.Api.actions.read) {
\r
103 this.onRead(action, trans, result, res);
\r
105 this.onWrite(action, trans, result, res, rs);
\r
110 * Callback for read actions
\r
111 * @param {String} action [Ext.data.Api.actions.create|read|update|destroy]
\r
112 * @param {Object} trans The request transaction object
\r
113 * @param {Object} res The server response
\r
116 onRead : function(action, trans, result, res) {
\r
119 records = trans.reader.readRecords(result);
\r
122 // @deprecated: Fire old loadexception for backwards-compat.
\r
123 this.fireEvent("loadexception", this, trans, res, ex);
\r
125 this.fireEvent('exception', this, 'response', action, trans, res, ex);
\r
126 trans.request.callback.call(trans.request.scope, null, trans.request.arg, false);
\r
129 this.fireEvent("load", this, res, trans.request.arg);
\r
130 trans.request.callback.call(trans.request.scope, records, trans.request.arg, true);
\r
133 * Callback for write actions
\r
134 * @param {String} action [Ext.data.Api.actions.create|read|update|destroy]
\r
135 * @param {Object} trans The request transaction object
\r
136 * @param {Object} res The server response
\r
139 onWrite : function(action, trans, result, res, rs) {
\r
140 this.fireEvent("write", this, action, result, res, rs, trans.request.arg);
\r
141 trans.request.callback.call(trans.request.scope, result, res, true);
\r