Upgrade to ExtJS 3.1.1 - Released 02/08/2010
[extjs.git] / src / data / DataProxy.js
1 /*!
2  * Ext JS Library 3.1.1
3  * Copyright(c) 2006-2010 Ext JS, LLC
4  * licensing@extjs.com
5  * http://www.extjs.com/license
6  */
7 /**\r
8  * @class Ext.data.DataProxy\r
9  * @extends Ext.util.Observable\r
10  * <p>Abstract base class for implementations which provide retrieval of unformatted data objects.\r
11  * This class is intended to be extended and should not be created directly. For existing implementations,\r
12  * see {@link Ext.data.DirectProxy}, {@link Ext.data.HttpProxy}, {@link Ext.data.ScriptTagProxy} and\r
13  * {@link Ext.data.MemoryProxy}.</p>\r
14  * <p>DataProxy implementations are usually used in conjunction with an implementation of {@link Ext.data.DataReader}\r
15  * (of the appropriate type which knows how to parse the data object) to provide a block of\r
16  * {@link Ext.data.Records} to an {@link Ext.data.Store}.</p>\r
17  * <p>The parameter to a DataProxy constructor may be an {@link Ext.data.Connection} or can also be the\r
18  * config object to an {@link Ext.data.Connection}.</p>\r
19  * <p>Custom implementations must implement either the <code><b>doRequest</b></code> method (preferred) or the\r
20  * <code>load</code> method (deprecated). See\r
21  * {@link Ext.data.HttpProxy}.{@link Ext.data.HttpProxy#doRequest doRequest} or\r
22  * {@link Ext.data.HttpProxy}.{@link Ext.data.HttpProxy#load load} for additional details.</p>\r
23  * <p><b><u>Example 1</u></b></p>\r
24  * <pre><code>\r
25 proxy: new Ext.data.ScriptTagProxy({\r
26     {@link Ext.data.Connection#url url}: 'http://extjs.com/forum/topics-remote.php'\r
27 }),\r
28  * </code></pre>\r
29  * <p><b><u>Example 2</u></b></p>\r
30  * <pre><code>\r
31 proxy : new Ext.data.HttpProxy({\r
32     {@link Ext.data.Connection#method method}: 'GET',\r
33     {@link Ext.data.HttpProxy#prettyUrls prettyUrls}: false,\r
34     {@link Ext.data.Connection#url url}: 'local/default.php', // see options parameter for {@link Ext.Ajax#request}\r
35     {@link #api}: {\r
36         // all actions except the following will use above url\r
37         create  : 'local/new.php',\r
38         update  : 'local/update.php'\r
39     }\r
40 }),\r
41  * </code></pre>\r
42  * <p>And <b>new in Ext version 3</b>, attach centralized event-listeners upon the DataProxy class itself!  This is a great place\r
43  * to implement a <i>messaging system</i> to centralize your application's user-feedback and error-handling.</p>\r
44  * <pre><code>\r
45 // Listen to all "beforewrite" event fired by all proxies.\r
46 Ext.data.DataProxy.on('beforewrite', function(proxy, action) {\r
47     console.log('beforewrite: ', action);\r
48 });\r
49 \r
50 // Listen to "write" event fired by all proxies\r
51 Ext.data.DataProxy.on('write', function(proxy, action, data, res, rs) {\r
52     console.info('write: ', action);\r
53 });\r
54 \r
55 // Listen to "exception" event fired by all proxies\r
56 Ext.data.DataProxy.on('exception', function(proxy, type, action) {\r
57     console.error(type + action + ' exception);\r
58 });\r
59  * </code></pre>\r
60  * <b>Note:</b> These three events are all fired with the signature of the corresponding <i>DataProxy instance</i> event {@link #beforewrite beforewrite}, {@link #write write} and {@link #exception exception}.\r
61  */\r
62 Ext.data.DataProxy = function(conn){\r
63     // make sure we have a config object here to support ux proxies.\r
64     // All proxies should now send config into superclass constructor.\r
65     conn = conn || {};\r
66 \r
67     // This line caused a bug when people use custom Connection object having its own request method.\r
68     // http://extjs.com/forum/showthread.php?t=67194.  Have to set DataProxy config\r
69     //Ext.applyIf(this, conn);\r
70 \r
71     this.api     = conn.api;\r
72     this.url     = conn.url;\r
73     this.restful = conn.restful;\r
74     this.listeners = conn.listeners;\r
75 \r
76     // deprecated\r
77     this.prettyUrls = conn.prettyUrls;\r
78 \r
79     /**\r
80      * @cfg {Object} api\r
81      * Specific urls to call on CRUD action methods "read", "create", "update" and "destroy".\r
82      * Defaults to:<pre><code>\r
83 api: {\r
84     read    : undefined,\r
85     create  : undefined,\r
86     update  : undefined,\r
87     destroy : undefined\r
88 }\r
89      * </code></pre>\r
90      * <p>The url is built based upon the action being executed <tt>[load|create|save|destroy]</tt>\r
91      * using the commensurate <tt>{@link #api}</tt> property, or if undefined default to the\r
92      * configured {@link Ext.data.Store}.{@link Ext.data.Store#url url}.</p><br>\r
93      * <p>For example:</p>\r
94      * <pre><code>\r
95 api: {\r
96     load :    '/controller/load',\r
97     create :  '/controller/new',  // Server MUST return idProperty of new record\r
98     save :    '/controller/update',\r
99     destroy : '/controller/destroy_action'\r
100 }\r
101 \r
102 // Alternatively, one can use the object-form to specify each API-action\r
103 api: {\r
104     load: {url: 'read.php', method: 'GET'},\r
105     create: 'create.php',\r
106     destroy: 'destroy.php',\r
107     save: 'update.php'\r
108 }\r
109      * </code></pre>\r
110      * <p>If the specific URL for a given CRUD action is undefined, the CRUD action request\r
111      * will be directed to the configured <tt>{@link Ext.data.Connection#url url}</tt>.</p>\r
112      * <br><p><b>Note</b>: To modify the URL for an action dynamically the appropriate API\r
113      * property should be modified before the action is requested using the corresponding before\r
114      * action event.  For example to modify the URL associated with the load action:\r
115      * <pre><code>\r
116 // modify the url for the action\r
117 myStore.on({\r
118     beforeload: {\r
119         fn: function (store, options) {\r
120             // use <tt>{@link Ext.data.HttpProxy#setUrl setUrl}</tt> to change the URL for *just* this request.\r
121             store.proxy.setUrl('changed1.php');\r
122 \r
123             // set optional second parameter to true to make this URL change\r
124             // permanent, applying this URL for all subsequent requests.\r
125             store.proxy.setUrl('changed1.php', true);\r
126 \r
127             // Altering the proxy API should be done using the public\r
128             // method <tt>{@link Ext.data.DataProxy#setApi setApi}</tt>.\r
129             store.proxy.setApi('read', 'changed2.php');\r
130 \r
131             // Or set the entire API with a config-object.\r
132             // When using the config-object option, you must redefine the <b>entire</b>\r
133             // API -- not just a specific action of it.\r
134             store.proxy.setApi({\r
135                 read    : 'changed_read.php',\r
136                 create  : 'changed_create.php',\r
137                 update  : 'changed_update.php',\r
138                 destroy : 'changed_destroy.php'\r
139             });\r
140         }\r
141     }\r
142 });\r
143      * </code></pre>\r
144      * </p>\r
145      */\r
146 \r
147     this.addEvents(\r
148         /**\r
149          * @event exception\r
150          * <p>Fires if an exception occurs in the Proxy during a remote request. This event is relayed\r
151          * through a corresponding {@link Ext.data.Store}.{@link Ext.data.Store#exception exception},\r
152          * so any Store instance may observe this event.</p>\r
153          * <p>In addition to being fired through the DataProxy instance that raised the event, this event is also fired\r
154          * through the Ext.data.DataProxy <i>class</i> to allow for centralized processing of exception events from <b>all</b>\r
155          * DataProxies by attaching a listener to the Ext.data.Proxy class itself.</p>\r
156          * <p>This event can be fired for one of two reasons:</p>\r
157          * <div class="mdetail-params"><ul>\r
158          * <li>remote-request <b>failed</b> : <div class="sub-desc">\r
159          * The server did not return status === 200.\r
160          * </div></li>\r
161          * <li>remote-request <b>succeeded</b> : <div class="sub-desc">\r
162          * The remote-request succeeded but the reader could not read the response.\r
163          * This means the server returned data, but the configured Reader threw an\r
164          * error while reading the response.  In this case, this event will be\r
165          * raised and the caught error will be passed along into this event.\r
166          * </div></li>\r
167          * </ul></div>\r
168          * <br><p>This event fires with two different contexts based upon the 2nd\r
169          * parameter <tt>type [remote|response]</tt>.  The first four parameters\r
170          * are identical between the two contexts -- only the final two parameters\r
171          * differ.</p>\r
172          * @param {DataProxy} this The proxy that sent the request\r
173          * @param {String} type\r
174          * <p>The value of this parameter will be either <tt>'response'</tt> or <tt>'remote'</tt>.</p>\r
175          * <div class="mdetail-params"><ul>\r
176          * <li><b><tt>'response'</tt></b> : <div class="sub-desc">\r
177          * <p>An <b>invalid</b> response from the server was returned: either 404,\r
178          * 500 or the response meta-data does not match that defined in the DataReader\r
179          * (e.g.: root, idProperty, successProperty).</p>\r
180          * </div></li>\r
181          * <li><b><tt>'remote'</tt></b> : <div class="sub-desc">\r
182          * <p>A <b>valid</b> response was returned from the server having\r
183          * successProperty === false.  This response might contain an error-message\r
184          * sent from the server.  For example, the user may have failed\r
185          * authentication/authorization or a database validation error occurred.</p>\r
186          * </div></li>\r
187          * </ul></div>\r
188          * @param {String} action Name of the action (see {@link Ext.data.Api#actions}.\r
189          * @param {Object} options The options for the action that were specified in the {@link #request}.\r
190          * @param {Object} response\r
191          * <p>The value of this parameter depends on the value of the <code>type</code> parameter:</p>\r
192          * <div class="mdetail-params"><ul>\r
193          * <li><b><tt>'response'</tt></b> : <div class="sub-desc">\r
194          * <p>The raw browser response object (e.g.: XMLHttpRequest)</p>\r
195          * </div></li>\r
196          * <li><b><tt>'remote'</tt></b> : <div class="sub-desc">\r
197          * <p>The decoded response object sent from the server.</p>\r
198          * </div></li>\r
199          * </ul></div>\r
200          * @param {Mixed} arg\r
201          * <p>The type and value of this parameter depends on the value of the <code>type</code> parameter:</p>\r
202          * <div class="mdetail-params"><ul>\r
203          * <li><b><tt>'response'</tt></b> : Error<div class="sub-desc">\r
204          * <p>The JavaScript Error object caught if the configured Reader could not read the data.\r
205          * If the remote request returns success===false, this parameter will be null.</p>\r
206          * </div></li>\r
207          * <li><b><tt>'remote'</tt></b> : Record/Record[]<div class="sub-desc">\r
208          * <p>This parameter will only exist if the <tt>action</tt> was a <b>write</b> action\r
209          * (Ext.data.Api.actions.create|update|destroy).</p>\r
210          * </div></li>\r
211          * </ul></div>\r
212          */\r
213         'exception',\r
214         /**\r
215          * @event beforeload\r
216          * Fires before a request to retrieve a data object.\r
217          * @param {DataProxy} this The proxy for the request\r
218          * @param {Object} params The params object passed to the {@link #request} function\r
219          */\r
220         'beforeload',\r
221         /**\r
222          * @event load\r
223          * Fires before the load method's callback is called.\r
224          * @param {DataProxy} this The proxy for the request\r
225          * @param {Object} o The request transaction object\r
226          * @param {Object} options The callback's <tt>options</tt> property as passed to the {@link #request} function\r
227          */\r
228         'load',\r
229         /**\r
230          * @event loadexception\r
231          * <p>This event is <b>deprecated</b>.  The signature of the loadexception event\r
232          * varies depending on the proxy, use the catch-all {@link #exception} event instead.\r
233          * This event will fire in addition to the {@link #exception} event.</p>\r
234          * @param {misc} misc See {@link #exception}.\r
235          * @deprecated\r
236          */\r
237         'loadexception',\r
238         /**\r
239          * @event beforewrite\r
240          * <p>Fires before a request is generated for one of the actions Ext.data.Api.actions.create|update|destroy</p>\r
241          * <p>In addition to being fired through the DataProxy instance that raised the event, this event is also fired\r
242          * through the Ext.data.DataProxy <i>class</i> to allow for centralized processing of beforewrite events from <b>all</b>\r
243          * DataProxies by attaching a listener to the Ext.data.Proxy class itself.</p>\r
244          * @param {DataProxy} this The proxy for the request\r
245          * @param {String} action [Ext.data.Api.actions.create|update|destroy]\r
246          * @param {Record/Array[Record]} rs The Record(s) to create|update|destroy.\r
247          * @param {Object} params The request <code>params</code> object.  Edit <code>params</code> to add parameters to the request.\r
248          */\r
249         'beforewrite',\r
250         /**\r
251          * @event write\r
252          * <p>Fires before the request-callback is called</p>\r
253          * <p>In addition to being fired through the DataProxy instance that raised the event, this event is also fired\r
254          * through the Ext.data.DataProxy <i>class</i> to allow for centralized processing of write events from <b>all</b>\r
255          * DataProxies by attaching a listener to the Ext.data.Proxy class itself.</p>\r
256          * @param {DataProxy} this The proxy that sent the request\r
257          * @param {String} action [Ext.data.Api.actions.create|upate|destroy]\r
258          * @param {Object} data The data object extracted from the server-response\r
259          * @param {Object} response The decoded response from server\r
260          * @param {Record/Record{}} rs The records from Store\r
261          * @param {Object} options The callback's <tt>options</tt> property as passed to the {@link #request} function\r
262          */\r
263         'write'\r
264     );\r
265     Ext.data.DataProxy.superclass.constructor.call(this);\r
266 \r
267     // Prepare the proxy api.  Ensures all API-actions are defined with the Object-form.\r
268     try {\r
269         Ext.data.Api.prepare(this);\r
270     } catch (e) {\r
271         if (e instanceof Ext.data.Api.Error) {\r
272             e.toConsole();\r
273         }\r
274     }\r
275     // relay each proxy's events onto Ext.data.DataProxy class for centralized Proxy-listening\r
276     Ext.data.DataProxy.relayEvents(this, ['beforewrite', 'write', 'exception']);\r
277 };\r
278 \r
279 Ext.extend(Ext.data.DataProxy, Ext.util.Observable, {\r
280     /**\r
281      * @cfg {Boolean} restful\r
282      * <p>Defaults to <tt>false</tt>.  Set to <tt>true</tt> to operate in a RESTful manner.</p>\r
283      * <br><p> Note: this parameter will automatically be set to <tt>true</tt> if the\r
284      * {@link Ext.data.Store} it is plugged into is set to <code>restful: true</code>. If the\r
285      * Store is RESTful, there is no need to set this option on the proxy.</p>\r
286      * <br><p>RESTful implementations enable the serverside framework to automatically route\r
287      * actions sent to one url based upon the HTTP method, for example:\r
288      * <pre><code>\r
289 store: new Ext.data.Store({\r
290     restful: true,\r
291     proxy: new Ext.data.HttpProxy({url:'/users'}); // all requests sent to /users\r
292     ...\r
293 )}\r
294      * </code></pre>\r
295      * If there is no <code>{@link #api}</code> specified in the configuration of the proxy,\r
296      * all requests will be marshalled to a single RESTful url (/users) so the serverside\r
297      * framework can inspect the HTTP Method and act accordingly:\r
298      * <pre>\r
299 <u>Method</u>   <u>url</u>        <u>action</u>\r
300 POST     /users     create\r
301 GET      /users     read\r
302 PUT      /users/23  update\r
303 DESTROY  /users/23  delete\r
304      * </pre></p>\r
305      * <p>If set to <tt>true</tt>, a {@link Ext.data.Record#phantom non-phantom} record's\r
306      * {@link Ext.data.Record#id id} will be appended to the url. Some MVC (e.g., Ruby on Rails,\r
307      * Merb and Django) support segment based urls where the segments in the URL follow the\r
308      * Model-View-Controller approach:<pre><code>\r
309      * someSite.com/controller/action/id\r
310      * </code></pre>\r
311      * Where the segments in the url are typically:<div class="mdetail-params"><ul>\r
312      * <li>The first segment : represents the controller class that should be invoked.</li>\r
313      * <li>The second segment : represents the class function, or method, that should be called.</li>\r
314      * <li>The third segment : represents the ID (a variable typically passed to the method).</li>\r
315      * </ul></div></p>\r
316      * <br><p>Refer to <code>{@link Ext.data.DataProxy#api}</code> for additional information.</p>\r
317      */\r
318     restful: false,\r
319 \r
320     /**\r
321      * <p>Redefines the Proxy's API or a single action of an API. Can be called with two method signatures.</p>\r
322      * <p>If called with an object as the only parameter, the object should redefine the <b>entire</b> API, e.g.:</p><pre><code>\r
323 proxy.setApi({\r
324     read    : '/users/read',\r
325     create  : '/users/create',\r
326     update  : '/users/update',\r
327     destroy : '/users/destroy'\r
328 });\r
329 </code></pre>\r
330      * <p>If called with two parameters, the first parameter should be a string specifying the API action to\r
331      * redefine and the second parameter should be the URL (or function if using DirectProxy) to call for that action, e.g.:</p><pre><code>\r
332 proxy.setApi(Ext.data.Api.actions.read, '/users/new_load_url');\r
333 </code></pre>\r
334      * @param {String/Object} api An API specification object, or the name of an action.\r
335      * @param {String/Function} url The URL (or function if using DirectProxy) to call for the action.\r
336      */\r
337     setApi : function() {\r
338         if (arguments.length == 1) {\r
339             var valid = Ext.data.Api.isValid(arguments[0]);\r
340             if (valid === true) {\r
341                 this.api = arguments[0];\r
342             }\r
343             else {\r
344                 throw new Ext.data.Api.Error('invalid', valid);\r
345             }\r
346         }\r
347         else if (arguments.length == 2) {\r
348             if (!Ext.data.Api.isAction(arguments[0])) {\r
349                 throw new Ext.data.Api.Error('invalid', arguments[0]);\r
350             }\r
351             this.api[arguments[0]] = arguments[1];\r
352         }\r
353         Ext.data.Api.prepare(this);\r
354     },\r
355 \r
356     /**\r
357      * Returns true if the specified action is defined as a unique action in the api-config.\r
358      * request.  If all API-actions are routed to unique urls, the xaction parameter is unecessary.  However, if no api is defined\r
359      * and all Proxy actions are routed to DataProxy#url, the server-side will require the xaction parameter to perform a switch to\r
360      * the corresponding code for CRUD action.\r
361      * @param {String [Ext.data.Api.CREATE|READ|UPDATE|DESTROY]} action\r
362      * @return {Boolean}\r
363      */\r
364     isApiAction : function(action) {\r
365         return (this.api[action]) ? true : false;\r
366     },\r
367 \r
368     /**\r
369      * All proxy actions are executed through this method.  Automatically fires the "before" + action event\r
370      * @param {String} action Name of the action\r
371      * @param {Ext.data.Record/Ext.data.Record[]/null} rs Will be null when action is 'load'\r
372      * @param {Object} params\r
373      * @param {Ext.data.DataReader} reader\r
374      * @param {Function} callback\r
375      * @param {Object} scope The scope (<code>this</code> reference) in which the callback function is executed. Defaults to the Proxy object.\r
376      * @param {Object} options Any options specified for the action (e.g. see {@link Ext.data.Store#load}.\r
377      */\r
378     request : function(action, rs, params, reader, callback, scope, options) {\r
379         if (!this.api[action] && !this.load) {\r
380             throw new Ext.data.DataProxy.Error('action-undefined', action);\r
381         }\r
382         params = params || {};\r
383         if ((action === Ext.data.Api.actions.read) ? this.fireEvent("beforeload", this, params) : this.fireEvent("beforewrite", this, action, rs, params) !== false) {\r
384             this.doRequest.apply(this, arguments);\r
385         }\r
386         else {\r
387             callback.call(scope || this, null, options, false);\r
388         }\r
389     },\r
390 \r
391 \r
392     /**\r
393      * <b>Deprecated</b> load method using old method signature. See {@doRequest} for preferred method.\r
394      * @deprecated\r
395      * @param {Object} params\r
396      * @param {Object} reader\r
397      * @param {Object} callback\r
398      * @param {Object} scope\r
399      * @param {Object} arg\r
400      */\r
401     load : null,\r
402 \r
403     /**\r
404      * @cfg {Function} doRequest Abstract method that should be implemented in all subclasses.  <b>Note:</b> Should only be used by custom-proxy developers.\r
405      * (e.g.: {@link Ext.data.HttpProxy#doRequest HttpProxy.doRequest},\r
406      * {@link Ext.data.DirectProxy#doRequest DirectProxy.doRequest}).\r
407      */\r
408     doRequest : function(action, rs, params, reader, callback, scope, options) {\r
409         // default implementation of doRequest for backwards compatibility with 2.0 proxies.\r
410         // If we're executing here, the action is probably "load".\r
411         // Call with the pre-3.0 method signature.\r
412         this.load(params, reader, callback, scope, options);\r
413     },\r
414 \r
415     /**\r
416      * @cfg {Function} onRead Abstract method that should be implemented in all subclasses.  <b>Note:</b> Should only be used by custom-proxy developers.  Callback for read {@link Ext.data.Api#actions action}.\r
417      * @param {String} action Action name as per {@link Ext.data.Api.actions#read}.\r
418      * @param {Object} o The request transaction object\r
419      * @param {Object} res The server response\r
420      * @fires loadexception (deprecated)\r
421      * @fires exception\r
422      * @fires load\r
423      * @protected\r
424      */\r
425     onRead : Ext.emptyFn,\r
426     /**\r
427      * @cfg {Function} onWrite Abstract method that should be implemented in all subclasses.  <b>Note:</b> Should only be used by custom-proxy developers.  Callback for <i>create, update and destroy</i> {@link Ext.data.Api#actions actions}.\r
428      * @param {String} action [Ext.data.Api.actions.create|read|update|destroy]\r
429      * @param {Object} trans The request transaction object\r
430      * @param {Object} res The server response\r
431      * @fires exception\r
432      * @fires write\r
433      * @protected\r
434      */\r
435     onWrite : Ext.emptyFn,\r
436     /**\r
437      * buildUrl\r
438      * Sets the appropriate url based upon the action being executed.  If restful is true, and only a single record is being acted upon,\r
439      * url will be built Rails-style, as in "/controller/action/32".  restful will aply iff the supplied record is an\r
440      * instance of Ext.data.Record rather than an Array of them.\r
441      * @param {String} action The api action being executed [read|create|update|destroy]\r
442      * @param {Ext.data.Record/Array[Ext.data.Record]} The record or Array of Records being acted upon.\r
443      * @return {String} url\r
444      * @private\r
445      */\r
446     buildUrl : function(action, record) {\r
447         record = record || null;\r
448 \r
449         // conn.url gets nullified after each request.  If it's NOT null here, that means the user must have intervened with a call\r
450         // to DataProxy#setUrl or DataProxy#setApi and changed it before the request was executed.  If that's the case, use conn.url,\r
451         // otherwise, build the url from the api or this.url.\r
452         var url = (this.conn && this.conn.url) ? this.conn.url : (this.api[action]) ? this.api[action].url : this.url;\r
453         if (!url) {\r
454             throw new Ext.data.Api.Error('invalid-url', action);\r
455         }\r
456 \r
457         // look for urls having "provides" suffix used in some MVC frameworks like Rails/Merb and others.  The provides suffice informs\r
458         // the server what data-format the client is dealing with and returns data in the same format (eg: application/json, application/xml, etc)\r
459         // e.g.: /users.json, /users.xml, etc.\r
460         // with restful routes, we need urls like:\r
461         // PUT /users/1.json\r
462         // DELETE /users/1.json\r
463         var provides = null;\r
464         var m = url.match(/(.*)(\.json|\.xml|\.html)$/);\r
465         if (m) {\r
466             provides = m[2];    // eg ".json"\r
467             url      = m[1];    // eg: "/users"\r
468         }\r
469         // prettyUrls is deprectated in favor of restful-config\r
470         if ((this.restful === true || this.prettyUrls === true) && record instanceof Ext.data.Record && !record.phantom) {\r
471             url += '/' + record.id;\r
472         }\r
473         return (provides === null) ? url : url + provides;\r
474     },\r
475 \r
476     /**\r
477      * Destroys the proxy by purging any event listeners and cancelling any active requests.\r
478      */\r
479     destroy: function(){\r
480         this.purgeListeners();\r
481     }\r
482 });\r
483 \r
484 // Apply the Observable prototype to the DataProxy class so that proxy instances can relay their\r
485 // events to the class.  Allows for centralized listening of all proxy instances upon the DataProxy class.\r
486 Ext.apply(Ext.data.DataProxy, Ext.util.Observable.prototype);\r
487 Ext.util.Observable.call(Ext.data.DataProxy);\r
488 \r
489 /**\r
490  * @class Ext.data.DataProxy.Error\r
491  * @extends Ext.Error\r
492  * DataProxy Error extension.\r
493  * constructor\r
494  * @param {String} name\r
495  * @param {Record/Array[Record]/Array}\r
496  */\r
497 Ext.data.DataProxy.Error = Ext.extend(Ext.Error, {\r
498     constructor : function(message, arg) {\r
499         this.arg = arg;\r
500         Ext.Error.call(this, message);\r
501     },\r
502     name: 'Ext.data.DataProxy'\r
503 });\r
504 Ext.apply(Ext.data.DataProxy.Error.prototype, {\r
505     lang: {\r
506         'action-undefined': "DataProxy attempted to execute an API-action but found an undefined url / function.  Please review your Proxy url/api-configuration.",\r
507         'api-invalid': 'Recieved an invalid API-configuration.  Please ensure your proxy API-configuration contains only the actions from Ext.data.Api.actions.'\r
508     }\r
509 });\r
510 \r
511 \r