Alien-Web-ExtJS-V3

 view release on metacpan or  search on metacpan

share/docs/source/DataProxy.html  view on Meta::CPAN

</span> * @class Ext.data.DataProxy
 * @extends Ext.util.Observable
 * &lt;p&gt;Abstract base class for implementations which provide retrieval of unformatted data objects.
 * This class is intended to be extended and should not be created directly. For existing implementations,
 * see {@link Ext.data.DirectProxy}, {@link Ext.data.HttpProxy}, {@link Ext.data.ScriptTagProxy} and
 * {@link Ext.data.MemoryProxy}.&lt;/p&gt;
 * &lt;p&gt;DataProxy implementations are usually used in conjunction with an implementation of {@link Ext.data.DataReader}
 * (of the appropriate type which knows how to parse the data object) to provide a block of
 * {@link Ext.data.Records} to an {@link Ext.data.Store}.&lt;/p&gt;
 * &lt;p&gt;The parameter to a DataProxy constructor may be an {@link Ext.data.Connection} or can also be the
 * config object to an {@link Ext.data.Connection}.&lt;/p&gt;
 * &lt;p&gt;Custom implementations must implement either the &lt;code&gt;&lt;b&gt;doRequest&lt;/b&gt;&lt;/code&gt; method (preferred) or the
 * &lt;code&gt;load&lt;/code&gt; method (deprecated). See
 * {@link Ext.data.HttpProxy}.{@link Ext.data.HttpProxy#doRequest doRequest} or
 * {@link Ext.data.HttpProxy}.{@link Ext.data.HttpProxy#load load} for additional details.&lt;/p&gt;
 * &lt;p&gt;&lt;b&gt;&lt;u&gt;Example 1&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
 * &lt;pre&gt;&lt;code&gt;
proxy: new Ext.data.ScriptTagProxy({
    {@link Ext.data.Connection#url url}: 'http://extjs.com/forum/topics-remote.php'
}),
 * &lt;/code&gt;&lt;/pre&gt;
 * &lt;p&gt;&lt;b&gt;&lt;u&gt;Example 2&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
 * &lt;pre&gt;&lt;code&gt;
proxy : new Ext.data.HttpProxy({
    {@link Ext.data.Connection#method method}: 'GET',
    {@link Ext.data.HttpProxy#prettyUrls prettyUrls}: false,
    {@link Ext.data.Connection#url url}: 'local/default.php', // see options parameter for {@link Ext.Ajax#request}
    {@link #api}: {
        // all actions except the following will use above url
        create  : 'local/new.php',
        update  : 'local/update.php'
    }
}),
 * &lt;/code&gt;&lt;/pre&gt;
 * &lt;p&gt;And &lt;b&gt;new in Ext version 3&lt;/b&gt;, attach centralized event-listeners upon the DataProxy class itself!  This is a great place
 * to implement a &lt;i&gt;messaging system&lt;/i&gt; to centralize your application's user-feedback and error-handling.&lt;/p&gt;
 * &lt;pre&gt;&lt;code&gt;
// Listen to all &quot;beforewrite&quot; event fired by all proxies.
Ext.data.DataProxy.on('beforewrite', function(proxy, action) {
    console.log('beforewrite: ', action);
});

// Listen to &quot;write&quot; event fired by all proxies
Ext.data.DataProxy.on('write', function(proxy, action, data, res, rs) {
    console.info('write: ', action);
});

// Listen to &quot;exception&quot; event fired by all proxies
Ext.data.DataProxy.on('exception', function(proxy, type, action, exception) {
    console.error(type + action + ' exception);
});
 * &lt;/code&gt;&lt;/pre&gt;
 * &lt;b&gt;Note:&lt;/b&gt; These three events are all fired with the signature of the corresponding &lt;i&gt;DataProxy instance&lt;/i&gt; event {@link #beforewrite beforewrite}, {@link #write write} and {@link #exception exception}.
 */
Ext.data.DataProxy = function(conn){
    // make sure we have a config object here to support ux proxies.
    // All proxies should now send config into superclass constructor.
    conn = conn || {};

    // This line caused a bug when people use custom Connection object having its own request method.
    // http://extjs.com/forum/showthread.php?t=67194.  Have to set DataProxy config
    //Ext.applyIf(this, conn);

    this.api     = conn.api;
    this.url     = conn.url;
    this.restful = conn.restful;
    this.listeners = conn.listeners;

    // deprecated
    this.prettyUrls = conn.prettyUrls;

<span id='Ext-data-DataProxy-cfg-api'>    /**
</span>     * @cfg {Object} api
     * Specific urls to call on CRUD action methods &quot;read&quot;, &quot;create&quot;, &quot;update&quot; and &quot;destroy&quot;.
     * Defaults to:&lt;pre&gt;&lt;code&gt;
api: {
    read    : undefined,
    create  : undefined,
    update  : undefined,
    destroy : undefined
}
     * &lt;/code&gt;&lt;/pre&gt;
     * &lt;p&gt;The url is built based upon the action being executed &lt;tt&gt;[load|create|save|destroy]&lt;/tt&gt;
     * using the commensurate &lt;tt&gt;{@link #api}&lt;/tt&gt; property, or if undefined default to the
     * configured {@link Ext.data.Store}.{@link Ext.data.Store#url url}.&lt;/p&gt;&lt;br&gt;
     * &lt;p&gt;For example:&lt;/p&gt;
     * &lt;pre&gt;&lt;code&gt;
api: {
    load :    '/controller/load',
    create :  '/controller/new',  // Server MUST return idProperty of new record
    save :    '/controller/update',
    destroy : '/controller/destroy_action'
}

// Alternatively, one can use the object-form to specify each API-action
api: {
    load: {url: 'read.php', method: 'GET'},
    create: 'create.php',
    destroy: 'destroy.php',
    save: 'update.php'
}
     * &lt;/code&gt;&lt;/pre&gt;
     * &lt;p&gt;If the specific URL for a given CRUD action is undefined, the CRUD action request
     * will be directed to the configured &lt;tt&gt;{@link Ext.data.Connection#url url}&lt;/tt&gt;.&lt;/p&gt;
     * &lt;br&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: To modify the URL for an action dynamically the appropriate API
     * property should be modified before the action is requested using the corresponding before
     * action event.  For example to modify the URL associated with the load action:
     * &lt;pre&gt;&lt;code&gt;
// modify the url for the action
myStore.on({
    beforeload: {
        fn: function (store, options) {
            // use &lt;tt&gt;{@link Ext.data.HttpProxy#setUrl setUrl}&lt;/tt&gt; to change the URL for *just* this request.
            store.proxy.setUrl('changed1.php');

            // set optional second parameter to true to make this URL change
            // permanent, applying this URL for all subsequent requests.
            store.proxy.setUrl('changed1.php', true);

            // Altering the proxy API should be done using the public
            // method &lt;tt&gt;{@link Ext.data.DataProxy#setApi setApi}&lt;/tt&gt;.



( run in 1.034 second using v1.01-cache-2.11-cpan-02777c243ea )