Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / docs / output / Ext.data.Api.html
1 <div class="body-wrap" xmlns:ext="http://www.extjs.com"><div class="top-tools"><a class="inner-link" href="#Ext.data.Api-props"><img src="resources/images/default/s.gif" class="item-icon icon-prop">Properties</a>&#13;<a class="inner-link" href="#Ext.data.Api-methods"><img src="resources/images/default/s.gif" class="item-icon icon-method">Methods</a>&#13;<a class="inner-link" href="#Ext.data.Api-events"><img src="resources/images/default/s.gif" class="item-icon icon-event">Events</a>&#13;<a class="bookmark" href="../docs/?class=Ext.data.Api"><img src="resources/images/default/s.gif" class="item-icon icon-fav">Direct Link</a>&#13;</div><h1>Class <a href="source/Api.html#cls-Ext.data.Api">Ext.data.Api</a></h1><table cellspacing="0"><tr><td class="label">Package:</td><td class="hd-info">Ext.data</td></tr><tr><td class="label">Defined In:</td><td class="hd-info">Api.js</td></tr><tr><td class="label">Class:</td><td class="hd-info"><a href="source/Api.html#cls-Ext.data.Api">Api</a></td></tr><tr><td class="label">Extends:</td><td class="hd-info">Object</td></tr></table><div class="description">Ext.data.Api is a singleton designed to manage the data API including methods
2 for validating a developer's DataProxy API.  Defines variables for CRUD actions
3 create, read, update and destroy in addition to a mapping of RESTful HTTP methods
4 GET, POST, PUT and DELETE to CRUD actions.<br><br><i>This class is a singleton and cannot be created directly.</i></div><div class="hr"></div><a id="Ext.data.Api-props"></a><h2>Public Properties</h2><table cellspacing="0" class="member-table"><tbody><tr><th colspan="2" class="sig-header">Property</th><th class="msource-header">Defined By</th></tr><tr class="property-row expandable "><td class="micon"><a href="#expand" class="exi">&nbsp;</a></td><td class="sig"><a id="Ext.data.Api-actions"></a><b><a href="source/Api.html#prop-Ext.data.Api-actions">actions</a></b> : Object<div class="mdesc"><div class="short">Defined actions corresponding to remote actions:
5 actions: {
6     create  : 'create',  // Text representing the remote-...</div><div class="long">Defined actions corresponding to remote actions:
7 <pre><code>actions: {
8     create  : <em>'create'</em>,  <i>// Text representing the remote-action to create records on server.</i>
9     read    : <em>'read'</em>,    <i>// Text representing the remote-action to read/load data from server.</i>
10     update  : <em>'update'</em>,  <i>// Text representing the remote-action to update records on server.</i>
11     destroy : <em>'destroy'</em>  <i>// Text representing the remote-action to destroy records on server.</i>
12 }</code></pre></div></div></td><td class="msource">Api</td></tr><tr class="property-row expandable "><td class="micon"><a href="#expand" class="exi">&nbsp;</a></td><td class="sig"><a id="Ext.data.Api-restActions"></a><b><a href="source/Api.html#prop-Ext.data.Api-restActions">restActions</a></b> : Object<div class="mdesc"><div class="short">Defined {CRUD action}:{HTTP method} pairs to associate HTTP methods with the
13 corresponding actions for RESTful proxie...</div><div class="long">Defined {CRUD action}:{HTTP method} pairs to associate HTTP methods with the
14 corresponding actions for <a href="output/Ext.data.DataProxy.html#Ext.data.DataProxy-restful" ext:member="restful" ext:cls="Ext.data.DataProxy">RESTful proxies</a>.
15 Defaults to:
16 <pre><code>restActions : {
17     create  : <em>'POST'</em>,
18     read    : <em>'GET'</em>,
19     update  : <em>'PUT'</em>,
20     destroy : <em>'DELETE'</em>
21 },</code></pre></div></div></td><td class="msource">Api</td></tr></tbody></table><a id="Ext.data.Api-methods"></a><h2>Public Methods</h2><table cellspacing="0" class="member-table"><tbody><tr><th colspan="2" class="sig-header">Method</th><th class="msource-header">Defined By</th></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi">&nbsp;</a></td><td class="sig"><a id="Ext.data.Api-getVerb"></a><b><a href="source/Api.html#method-Ext.data.Api-getVerb">getVerb</a></b>(&nbsp;<code>String&nbsp;name</code>&nbsp;)
22     :
23                                         String||null<div class="mdesc"><div class="short">Returns the actual CRUD action KEY "create", "read", "update" or "destroy" from the supplied action-name.  This metho...</div><div class="long">Returns the actual CRUD action KEY "create", "read", "update" or "destroy" from the supplied action-name.  This method is used internally and shouldn't generally
24 need to be used directly.  The key/value pair of Ext.data.Api.actions will often be identical but this is not necessarily true.  A developer can override this naming
25 convention if desired.  However, the framework internally calls methods based upon the KEY so a way of retreiving the the words "create", "read", "update" and "destroy" is
26 required.  This method will cache discovered KEYS into the private validActions hash.<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>name</code> : String<div class="sub-desc">The runtime name of the action.</div></li></ul><strong>Returns:</strong><ul><li><code>String||null</code><div class="sub-desc">returns the action-key, or verb of the user-action or null if invalid.</div></li></ul></div></div></div></td><td class="msource">Api</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi">&nbsp;</a></td><td class="sig"><a id="Ext.data.Api-hasUniqueUrl"></a><b><a href="source/Api.html#method-Ext.data.Api-hasUniqueUrl">hasUniqueUrl</a></b>(&nbsp;<code>Ext.data.DataProxy&nbsp;proxy</code>,&nbsp;<code>String&nbsp;verb</code>&nbsp;)
27     :
28                                         Boolean<div class="mdesc"><div class="short">Returns true if the supplied verb upon the supplied proxy points to a unique url in that none of the other api-action...</div><div class="long">Returns true if the supplied verb upon the supplied proxy points to a unique url in that none of the other api-actions
29 point to the same url.  The question is important for deciding whether to insert the "xaction" HTTP parameter within an
30 Ajax request.  This method is used internally and shouldn't generally need to be called directly.<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>proxy</code> : Ext.data.DataProxy<div class="sub-desc"></div></li><li><code>verb</code> : String<div class="sub-desc"></div></li></ul><strong>Returns:</strong><ul><li><code>Boolean</code><div class="sub-desc"></div></li></ul></div></div></div></td><td class="msource">Api</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi">&nbsp;</a></td><td class="sig"><a id="Ext.data.Api-isAction"></a><b><a href="source/Api.html#method-Ext.data.Api-isAction">isAction</a></b>(&nbsp;<code>String&nbsp;action</code>,&nbsp;<code>String[]}(Optional)&nbsp;List</code>&nbsp;)
31     :
32                                         Boolean<div class="mdesc"><div class="short">Returns true if supplied action-name is a valid API action defined in actions constants</div><div class="long">Returns true if supplied action-name is a valid API action defined in <code><a href="output/Ext.data.Api.html#Ext.data.Api-actions" ext:member="actions" ext:cls="Ext.data.Api">actions</a></code> constants<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>action</code> : String<div class="sub-desc"></div></li><li><code>List</code> : String[]}(Optional)<div class="sub-desc">of available CRUD actions.  Pass in list when executing multiple times for efficiency.</div></li></ul><strong>Returns:</strong><ul><li><code>Boolean</code><div class="sub-desc"></div></li></ul></div></div></div></td><td class="msource">Api</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi">&nbsp;</a></td><td class="sig"><a id="Ext.data.Api-isValid"></a><b><a href="source/Api.html#method-Ext.data.Api-isValid">isValid</a></b>()
33     :
34                                         String[]||true<div class="mdesc"><div class="short">Returns true if the supplied API is valid; that is, check that all keys match defined actions
35 otherwise returns an ar...</div><div class="long">Returns true if the supplied API is valid; that is, check that all keys match defined actions
36 otherwise returns an array of mistakes.<div class="mdetail-params"><strong>Parameters:</strong><ul><li>None.</li></ul><strong>Returns:</strong><ul><li><code>String[]||true</code><div class="sub-desc"></div></li></ul></div></div></div></td><td class="msource">Api</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi">&nbsp;</a></td><td class="sig"><a id="Ext.data.Api-prepare"></a><b><a href="source/Api.html#method-Ext.data.Api-prepare">prepare</a></b>(&nbsp;<code>Ext.data.DataProxy&nbsp;proxy</code>&nbsp;)
37     :
38                                         void<div class="mdesc"><div class="short">This method is used internally by DataProxy and should not generally need to be used directly.
39 Each action of a DataP...</div><div class="long">This method is used internally by <tt><a href="output/Ext.data.DataProxy.html" ext:cls="Ext.data.DataProxy">DataProxy</a></tt> and should not generally need to be used directly.
40 Each action of a DataProxy api can be initially defined as either a String or an Object.  When specified as an object,
41 one can explicitly define the HTTP method (GET|POST) to use for each CRUD action.  This method will prepare the supplied API, setting
42 each action to the Object form.  If your API-actions do not explicitly define the HTTP method, the "method" configuration-parameter will
43 be used.  If the method configuration parameter is not specified, POST will be used.
44          <pre><code><b>new</b> Ext.data.HttpProxy({
45     method: <em>"POST"</em>,     <i>// <-- <b>default</b> HTTP method when not specified.</i>
46     api: {
47         create: <em>'create.php'</em>,
48         load: <em>'read.php'</em>,
49         save: <em>'save.php'</em>,
50         destroy: <em>'destroy.php'</em>
51     }
52 });
53
54 <i>// Alternatively, one can use the object-form to specify the API</i>
55 <b>new</b> Ext.data.HttpProxy({
56     api: {
57         load: {url: <em>'read.php'</em>, method: <em>'GET'</em>},
58         create: <em>'create.php'</em>,
59         destroy: <em>'destroy.php'</em>,
60         save: <em>'update.php'</em>
61     }
62 });</code></pre><div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>proxy</code> : Ext.data.DataProxy<div class="sub-desc"></div></li></ul><strong>Returns:</strong><ul><li>void</li></ul></div></div></div></td><td class="msource">Api</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi">&nbsp;</a></td><td class="sig"><a id="Ext.data.Api-restify"></a><b><a href="source/Api.html#method-Ext.data.Api-restify">restify</a></b>(&nbsp;<code>Ext.data.DataProxy&nbsp;proxy</code>&nbsp;)
63     :
64                                         void<div class="mdesc"><div class="short">Prepares a supplied Proxy to be RESTful.  Sets the HTTP method for each api-action to be one of
65 GET, POST, PUT, DELET...</div><div class="long">Prepares a supplied Proxy to be RESTful.  Sets the HTTP method for each api-action to be one of
66 GET, POST, PUT, DELETE according to the defined <a href="output/Ext.data.Api.html#Ext.data.Api-restActions" ext:member="restActions" ext:cls="Ext.data.Api">restActions</a>.<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>proxy</code> : Ext.data.DataProxy<div class="sub-desc"></div></li></ul><strong>Returns:</strong><ul><li>void</li></ul></div></div></div></td><td class="msource">Api</td></tr></tbody></table><a id="Ext.data.Api-events"></a><h2>Public Events</h2><div class="no-members">This class has no public events.</div></div>