Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / docs / source / RemotingProvider.html
index 3b8fd70..0566fb4 100644 (file)
-<html>\r
-<head>\r
-  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    \r
-  <title>The source code</title>\r
-    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
-    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
-</head>\r
-<body  onload="prettyPrint();">\r
-    <pre class="prettyprint lang-js"><div id="cls-Ext.direct.RemotingProvider"></div>/**\r
- * @class Ext.direct.RemotingProvider\r
- * @extends Ext.direct.JsonProvider\r
- * \r
- * <p>The {@link Ext.direct.RemotingProvider RemotingProvider} exposes access to\r
- * server side methods on the client (a remote procedure call (RPC) type of\r
- * connection where the client can initiate a procedure on the server).</p>\r
- * \r
- * <p>This allows for code to be organized in a fashion that is maintainable,\r
- * while providing a clear path between client and server, something that is\r
- * not always apparent when using URLs.</p>\r
- * \r
- * <p>To accomplish this the server-side needs to describe what classes and methods\r
- * are available on the client-side. This configuration will typically be\r
- * outputted by the server-side Ext.Direct stack when the API description is built.</p>\r
- */\r
-Ext.direct.RemotingProvider = Ext.extend(Ext.direct.JsonProvider, {       \r
-    <div id="cfg-Ext.direct.RemotingProvider-actions"></div>/**\r
-     * @cfg {Object} actions\r
-     * Object literal defining the server side actions and methods. For example, if\r
-     * the Provider is configured with:\r
-     * <pre><code>\r
-"actions":{ // each property within the 'actions' object represents a server side Class \r
-    "TestAction":[ // array of methods within each server side Class to be   \r
-    {              // stubbed out on client\r
-        "name":"doEcho", \r
-        "len":1            \r
-    },{\r
-        "name":"multiply",// name of method\r
-        "len":2           // The number of parameters that will be used to create an\r
-                          // array of data to send to the server side function.\r
-                          // Ensure the server sends back a Number, not a String. \r
-    },{\r
-        "name":"doForm",\r
-        "formHandler":true, // direct the client to use specialized form handling method \r
-        "len":1\r
-    }]\r
-}\r
-     * </code></pre>\r
-     * <p>Note that a Store is not required, a server method can be called at any time.\r
-     * In the following example a <b>client side</b> handler is used to call the\r
-     * server side method "multiply" in the server-side "TestAction" Class:</p>\r
-     * <pre><code>\r
-TestAction.multiply(\r
-    2, 4, // pass two arguments to server, so specify len=2\r
-    // callback function after the server is called\r
-    // result: the result returned by the server\r
-    //      e: Ext.Direct.RemotingEvent object\r
-    function(result, e){\r
-        var t = e.getTransaction();\r
-        var action = t.action; // server side Class called\r
-        var method = t.method; // server side method called\r
-        if(e.status){\r
-            var answer = Ext.encode(result); // 8\r
-    \r
-        }else{\r
-            var msg = e.message; // failure message\r
-        }\r
-    }\r
-);\r
-     * </code></pre>\r
-     * In the example above, the server side "multiply" function will be passed two\r
-     * arguments (2 and 4).  The "multiply" method should return the value 8 which will be\r
-     * available as the <tt>result</tt> in the example above. \r
-     */\r
-    \r
-    <div id="cfg-Ext.direct.RemotingProvider-namespace"></div>/**\r
-     * @cfg {String/Object} namespace\r
-     * Namespace for the Remoting Provider (defaults to the browser global scope of <i>window</i>).\r
-     * Explicitly specify the namespace Object, or specify a String to have a\r
-     * {@link Ext#namespace namespace created} implicitly.\r
-     */\r
-    \r
-    <div id="cfg-Ext.direct.RemotingProvider-url"></div>/**\r
-     * @cfg {String} url\r
-     * <b>Required<b>. The url to connect to the {@link Ext.Direct} server-side router. \r
-     */\r
-    \r
-    <div id="cfg-Ext.direct.RemotingProvider-enableUrlEncode"></div>/**\r
-     * @cfg {String} enableUrlEncode\r
-     * Specify which param will hold the arguments for the method.\r
-     * Defaults to <tt>'data'</tt>.\r
-     */\r
-    \r
-    <div id="cfg-Ext.direct.RemotingProvider-enableBuffer"></div>/**\r
-     * @cfg {Number/Boolean} enableBuffer\r
-     * <p><tt>true</tt> or <tt>false</tt> to enable or disable combining of method\r
-     * calls. If a number is specified this is the amount of time in milliseconds\r
-     * to wait before sending a batched request (defaults to <tt>10</tt>).</p>\r
-     * <br><p>Calls which are received within the specified timeframe will be\r
-     * concatenated together and sent in a single request, optimizing the\r
-     * application by reducing the amount of round trips that have to be made\r
-     * to the server.</p>\r
-     */\r
-    enableBuffer: 10,\r
-    \r
-    <div id="cfg-Ext.direct.RemotingProvider-maxRetries"></div>/**\r
-     * @cfg {Number} maxRetries\r
-     * Number of times to re-attempt delivery on failure of a call. Defaults to <tt>1</tt>.\r
-     */\r
-    maxRetries: 1,\r
-    \r
-    <div id="cfg-Ext.direct.RemotingProvider-timeout"></div>/**\r
-     * @cfg {Number} timeout\r
-     * The timeout to use for each request. Defaults to <tt>undefined</tt>.\r
-     */\r
-    timeout: undefined,\r
-\r
-    constructor : function(config){\r
-        Ext.direct.RemotingProvider.superclass.constructor.call(this, config);\r
-        this.addEvents(\r
-            <div id="event-Ext.direct.RemotingProvider-beforecall"></div>/**\r
-             * @event beforecall\r
-             * Fires immediately before the client-side sends off the RPC call.\r
-             * By returning false from an event handler you can prevent the call from\r
-             * executing.\r
-             * @param {Ext.direct.RemotingProvider} provider\r
-             * @param {Ext.Direct.Transaction} transaction\r
-             */            \r
-            'beforecall',            \r
-            <div id="event-Ext.direct.RemotingProvider-call"></div>/**\r
-             * @event call\r
-             * Fires immediately after the request to the server-side is sent. This does\r
-             * NOT fire after the response has come back from the call.\r
-             * @param {Ext.direct.RemotingProvider} provider\r
-             * @param {Ext.Direct.Transaction} transaction\r
-             */            \r
-            'call'\r
-        );\r
-        this.namespace = (Ext.isString(this.namespace)) ? Ext.ns(this.namespace) : this.namespace || window;\r
-        this.transactions = {};\r
-        this.callBuffer = [];\r
-    },\r
-\r
-    // private\r
-    initAPI : function(){\r
-        var o = this.actions;\r
-        for(var c in o){\r
-            var cls = this.namespace[c] || (this.namespace[c] = {}),\r
-                ms = o[c];\r
-            for(var i = 0, len = ms.length; i < len; i++){\r
-                var m = ms[i];\r
-                cls[m.name] = this.createMethod(c, m);\r
-            }\r
-        }\r
-    },\r
-\r
-    // inherited\r
-    isConnected: function(){\r
-        return !!this.connected;\r
-    },\r
-\r
-    connect: function(){\r
-        if(this.url){\r
-            this.initAPI();\r
-            this.connected = true;\r
-            this.fireEvent('connect', this);\r
-        }else if(!this.url){\r
-            throw 'Error initializing RemotingProvider, no url configured.';\r
-        }\r
-    },\r
-\r
-    disconnect: function(){\r
-        if(this.connected){\r
-            this.connected = false;\r
-            this.fireEvent('disconnect', this);\r
-        }\r
-    },\r
-\r
-    onData: function(opt, success, xhr){\r
-        if(success){\r
-            var events = this.getEvents(xhr);\r
-            for(var i = 0, len = events.length; i < len; i++){\r
-                var e = events[i],\r
-                    t = this.getTransaction(e);\r
-                this.fireEvent('data', this, e);\r
-                if(t){\r
-                    this.doCallback(t, e, true);\r
-                    Ext.Direct.removeTransaction(t);\r
-                }\r
-            }\r
-        }else{\r
-            var ts = [].concat(opt.ts);\r
-            for(var i = 0, len = ts.length; i < len; i++){\r
-                var t = this.getTransaction(ts[i]);\r
-                if(t && t.retryCount < this.maxRetries){\r
-                    t.retry();\r
-                }else{\r
-                    var e = new Ext.Direct.ExceptionEvent({\r
-                        data: e,\r
-                        transaction: t,\r
-                        code: Ext.Direct.exceptions.TRANSPORT,\r
-                        message: 'Unable to connect to the server.',\r
-                        xhr: xhr\r
-                    });\r
-                    this.fireEvent('data', this, e);\r
-                    if(t){\r
-                        this.doCallback(t, e, false);\r
-                        Ext.Direct.removeTransaction(t);\r
-                    }\r
-                }\r
-            }\r
-        }\r
-    },\r
-\r
-    getCallData: function(t){\r
-        return {\r
-            action: t.action,\r
-            method: t.method,\r
-            data: t.data,\r
-            type: 'rpc',\r
-            tid: t.tid\r
-        };\r
-    },\r
-\r
-    doSend : function(data){\r
-        var o = {\r
-            url: this.url,\r
-            callback: this.onData,\r
-            scope: this,\r
-            ts: data,\r
-            timeout: this.timeout\r
-        }, callData;\r
-\r
-        if(Ext.isArray(data)){\r
-            callData = [];\r
-            for(var i = 0, len = data.length; i < len; i++){\r
-                callData.push(this.getCallData(data[i]));\r
-            }\r
-        }else{\r
-            callData = this.getCallData(data);\r
-        }\r
-\r
-        if(this.enableUrlEncode){\r
-            var params = {};\r
-            params[Ext.isString(this.enableUrlEncode) ? this.enableUrlEncode : 'data'] = Ext.encode(callData);\r
-            o.params = params;\r
-        }else{\r
-            o.jsonData = callData;\r
-        }\r
-        Ext.Ajax.request(o);\r
-    },\r
-\r
-    combineAndSend : function(){\r
-        var len = this.callBuffer.length;\r
-        if(len > 0){\r
-            this.doSend(len == 1 ? this.callBuffer[0] : this.callBuffer);\r
-            this.callBuffer = [];\r
-        }\r
-    },\r
-\r
-    queueTransaction: function(t){\r
-        if(t.form){\r
-            this.processForm(t);\r
-            return;\r
-        }\r
-        this.callBuffer.push(t);\r
-        if(this.enableBuffer){\r
-            if(!this.callTask){\r
-                this.callTask = new Ext.util.DelayedTask(this.combineAndSend, this);\r
-            }\r
-            this.callTask.delay(Ext.isNumber(this.enableBuffer) ? this.enableBuffer : 10);\r
-        }else{\r
-            this.combineAndSend();\r
-        }\r
-    },\r
-\r
-    doCall : function(c, m, args){\r
-        var data = null, hs = args[m.len], scope = args[m.len+1];\r
-\r
-        if(m.len !== 0){\r
-            data = args.slice(0, m.len);\r
-        }\r
-\r
-        var t = new Ext.Direct.Transaction({\r
-            provider: this,\r
-            args: args,\r
-            action: c,\r
-            method: m.name,\r
-            data: data,\r
-            cb: scope && Ext.isFunction(hs) ? hs.createDelegate(scope) : hs\r
-        });\r
-\r
-        if(this.fireEvent('beforecall', this, t) !== false){\r
-            Ext.Direct.addTransaction(t);\r
-            this.queueTransaction(t);\r
-            this.fireEvent('call', this, t);\r
-        }\r
-    },\r
-\r
-    doForm : function(c, m, form, callback, scope){\r
-        var t = new Ext.Direct.Transaction({\r
-            provider: this,\r
-            action: c,\r
-            method: m.name,\r
-            args:[form, callback, scope],\r
-            cb: scope && Ext.isFunction(callback) ? callback.createDelegate(scope) : callback,\r
-            isForm: true\r
-        });\r
-\r
-        if(this.fireEvent('beforecall', this, t) !== false){\r
-            Ext.Direct.addTransaction(t);\r
-            var isUpload = String(form.getAttribute("enctype")).toLowerCase() == 'multipart/form-data',\r
-                params = {\r
-                    extTID: t.tid,\r
-                    extAction: c,\r
-                    extMethod: m.name,\r
-                    extType: 'rpc',\r
-                    extUpload: String(isUpload)\r
-                };\r
-            \r
-            // change made from typeof callback check to callback.params\r
-            // to support addl param passing in DirectSubmit EAC 6/2\r
-            Ext.apply(t, {\r
-                form: Ext.getDom(form),\r
-                isUpload: isUpload,\r
-                params: callback && Ext.isObject(callback.params) ? Ext.apply(params, callback.params) : params\r
-            });\r
-            this.fireEvent('call', this, t);\r
-            this.processForm(t);\r
-        }\r
-    },\r
-    \r
-    processForm: function(t){\r
-        Ext.Ajax.request({\r
-            url: this.url,\r
-            params: t.params,\r
-            callback: this.onData,\r
-            scope: this,\r
-            form: t.form,\r
-            isUpload: t.isUpload,\r
-            ts: t\r
-        });\r
-    },\r
-\r
-    createMethod : function(c, m){\r
-        var f;\r
-        if(!m.formHandler){\r
-            f = function(){\r
-                this.doCall(c, m, Array.prototype.slice.call(arguments, 0));\r
-            }.createDelegate(this);\r
-        }else{\r
-            f = function(form, callback, scope){\r
-                this.doForm(c, m, form, callback, scope);\r
-            }.createDelegate(this);\r
-        }\r
-        f.directCfg = {\r
-            action: c,\r
-            method: m\r
-        };\r
-        return f;\r
-    },\r
-\r
-    getTransaction: function(opt){\r
-        return opt && opt.tid ? Ext.Direct.getTransaction(opt.tid) : null;\r
-    },\r
-\r
-    doCallback: function(t, e){\r
-        var fn = e.status ? 'success' : 'failure';\r
-        if(t && t.cb){\r
-            var hs = t.cb,\r
-                result = Ext.isDefined(e.result) ? e.result : e.data;\r
-            if(Ext.isFunction(hs)){\r
-                hs(result, e);\r
-            } else{\r
-                Ext.callback(hs[fn], hs.scope, [result, e]);\r
-                Ext.callback(hs.callback, hs.scope, [result, e]);\r
-            }\r
-        }\r
-    }\r
-});\r
-Ext.Direct.PROVIDERS['remoting'] = Ext.direct.RemotingProvider;</pre>    \r
-</body>\r
-</html>
\ No newline at end of file
+<!DOCTYPE html>
+<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>
+  <style type="text/css">
+    .highlight { display: block; background-color: #ddd; }
+  </style>
+  <script type="text/javascript">
+    function highlight() {
+      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
+    }
+  </script>
+</head>
+<body onload="prettyPrint(); highlight();">
+  <pre class="prettyprint lang-js"><span id='Ext-direct-RemotingProvider'>/**
+</span> * @class Ext.direct.RemotingProvider
+ * @extends Ext.direct.JsonProvider
+ * 
+ * &lt;p&gt;The {@link Ext.direct.RemotingProvider RemotingProvider} exposes access to
+ * server side methods on the client (a remote procedure call (RPC) type of
+ * connection where the client can initiate a procedure on the server).&lt;/p&gt;
+ * 
+ * &lt;p&gt;This allows for code to be organized in a fashion that is maintainable,
+ * while providing a clear path between client and server, something that is
+ * not always apparent when using URLs.&lt;/p&gt;
+ * 
+ * &lt;p&gt;To accomplish this the server-side needs to describe what classes and methods
+ * are available on the client-side. This configuration will typically be
+ * outputted by the server-side Ext.Direct stack when the API description is built.&lt;/p&gt;
+ */
+Ext.define('Ext.direct.RemotingProvider', {
+    
+    /* Begin Definitions */
+   
+    alias: 'direct.remotingprovider',
+    
+    extend: 'Ext.direct.JsonProvider', 
+    
+    requires: [
+        'Ext.util.MixedCollection', 
+        'Ext.util.DelayedTask', 
+        'Ext.direct.Transaction',
+        'Ext.direct.RemotingMethod'
+    ],
+   
+    /* End Definitions */
+   
+<span id='Ext-direct-RemotingProvider-cfg-actions'>   /**
+</span>     * @cfg {Object} actions
+     * Object literal defining the server side actions and methods. For example, if
+     * the Provider is configured with:
+     * &lt;pre&gt;&lt;code&gt;
+&quot;actions&quot;:{ // each property within the 'actions' object represents a server side Class 
+    &quot;TestAction&quot;:[ // array of methods within each server side Class to be   
+    {              // stubbed out on client
+        &quot;name&quot;:&quot;doEcho&quot;, 
+        &quot;len&quot;:1            
+    },{
+        &quot;name&quot;:&quot;multiply&quot;,// name of method
+        &quot;len&quot;:2           // The number of parameters that will be used to create an
+                          // array of data to send to the server side function.
+                          // Ensure the server sends back a Number, not a String. 
+    },{
+        &quot;name&quot;:&quot;doForm&quot;,
+        &quot;formHandler&quot;:true, // direct the client to use specialized form handling method 
+        &quot;len&quot;:1
+    }]
+}
+     * &lt;/code&gt;&lt;/pre&gt;
+     * &lt;p&gt;Note that a Store is not required, a server method can be called at any time.
+     * In the following example a &lt;b&gt;client side&lt;/b&gt; handler is used to call the
+     * server side method &quot;multiply&quot; in the server-side &quot;TestAction&quot; Class:&lt;/p&gt;
+     * &lt;pre&gt;&lt;code&gt;
+TestAction.multiply(
+    2, 4, // pass two arguments to server, so specify len=2
+    // callback function after the server is called
+    // result: the result returned by the server
+    //      e: Ext.direct.RemotingEvent object
+    function(result, e){
+        var t = e.getTransaction();
+        var action = t.action; // server side Class called
+        var method = t.method; // server side method called
+        if(e.status){
+            var answer = Ext.encode(result); // 8
+    
+        }else{
+            var msg = e.message; // failure message
+        }
+    }
+);
+     * &lt;/code&gt;&lt;/pre&gt;
+     * In the example above, the server side &quot;multiply&quot; function will be passed two
+     * arguments (2 and 4).  The &quot;multiply&quot; method should return the value 8 which will be
+     * available as the &lt;tt&gt;result&lt;/tt&gt; in the example above. 
+     */
+    
+<span id='Ext-direct-RemotingProvider-cfg-namespace'>    /**
+</span>     * @cfg {String/Object} namespace
+     * Namespace for the Remoting Provider (defaults to the browser global scope of &lt;i&gt;window&lt;/i&gt;).
+     * Explicitly specify the namespace Object, or specify a String to have a
+     * {@link Ext#namespace namespace created} implicitly.
+     */
+    
+<span id='Ext-direct-RemotingProvider-cfg-url'>    /**
+</span>     * @cfg {String} url
+     * &lt;b&gt;Required&lt;/b&gt;. The url to connect to the {@link Ext.direct.Manager} server-side router. 
+     */
+    
+<span id='Ext-direct-RemotingProvider-cfg-enableUrlEncode'>    /**
+</span>     * @cfg {String} enableUrlEncode
+     * Specify which param will hold the arguments for the method.
+     * Defaults to &lt;tt&gt;'data'&lt;/tt&gt;.
+     */
+    
+<span id='Ext-direct-RemotingProvider-cfg-enableBuffer'>    /**
+</span>     * @cfg {Number/Boolean} enableBuffer
+     * &lt;p&gt;&lt;tt&gt;true&lt;/tt&gt; or &lt;tt&gt;false&lt;/tt&gt; to enable or disable combining of method
+     * calls. If a number is specified this is the amount of time in milliseconds
+     * to wait before sending a batched request.&lt;/p&gt;
+     * &lt;br&gt;&lt;p&gt;Calls which are received within the specified timeframe will be
+     * concatenated together and sent in a single request, optimizing the
+     * application by reducing the amount of round trips that have to be made
+     * to the server.&lt;/p&gt;
+     */
+    enableBuffer: 10,
+    
+<span id='Ext-direct-RemotingProvider-cfg-maxRetries'>    /**
+</span>     * @cfg {Number} maxRetries
+     * Number of times to re-attempt delivery on failure of a call.
+     */
+    maxRetries: 1,
+    
+<span id='Ext-direct-RemotingProvider-cfg-timeout'>    /**
+</span>     * @cfg {Number} timeout
+     * The timeout to use for each request.
+     */
+    timeout: undefined,
+    
+    constructor : function(config){
+        var me = this;
+        me.callParent(arguments);
+        me.addEvents(
+<span id='Ext-direct-RemotingProvider-event-beforecall'>            /**
+</span>             * @event beforecall
+             * Fires immediately before the client-side sends off the RPC call.
+             * By returning false from an event handler you can prevent the call from
+             * executing.
+             * @param {Ext.direct.RemotingProvider} provider
+             * @param {Ext.direct.Transaction} transaction
+             * @param {Object} meta The meta data
+             */            
+            'beforecall',            
+<span id='Ext-direct-RemotingProvider-event-call'>            /**
+</span>             * @event call
+             * Fires immediately after the request to the server-side is sent. This does
+             * NOT fire after the response has come back from the call.
+             * @param {Ext.direct.RemotingProvider} provider
+             * @param {Ext.direct.Transaction} transaction
+             * @param {Object} meta The meta data
+             */            
+            'call'
+        );
+        me.namespace = (Ext.isString(me.namespace)) ? Ext.ns(me.namespace) : me.namespace || window;
+        me.transactions = Ext.create('Ext.util.MixedCollection');
+        me.callBuffer = [];
+    },
+    
+<span id='Ext-direct-RemotingProvider-method-initAPI'>    /**
+</span>     * Initialize the API
+     * @private
+     */
+    initAPI : function(){
+        var actions = this.actions,
+            namespace = this.namespace,
+            action,
+            cls,
+            methods,
+            i,
+            len,
+            method;
+            
+        for (action in actions) {
+            cls = namespace[action];
+            if (!cls) {
+                cls = namespace[action] = {};
+            }
+            methods = actions[action];
+            
+            for (i = 0, len = methods.length; i &lt; len; ++i) {
+                method = Ext.create('Ext.direct.RemotingMethod', methods[i]);
+                cls[method.name] = this.createHandler(action, method);
+            }
+        }
+    },
+    
+<span id='Ext-direct-RemotingProvider-method-createHandler'>    /**
+</span>     * Create a handler function for a direct call.
+     * @private
+     * @param {String} action The action the call is for
+     * @param {Object} method The details of the method
+     * @return {Function} A JS function that will kick off the call
+     */
+    createHandler : function(action, method){
+        var me = this,
+            handler;
+        
+        if (!method.formHandler) {
+            handler = function(){
+                me.configureRequest(action, method, Array.prototype.slice.call(arguments, 0));
+            };
+        } else {
+            handler = function(form, callback, scope){
+                me.configureFormRequest(action, method, form, callback, scope);
+            };
+        }
+        handler.directCfg = {
+            action: action,
+            method: method
+        };
+        return handler;
+    },
+    
+    // inherit docs
+    isConnected: function(){
+        return !!this.connected;
+    },
+
+    // inherit docs
+    connect: function(){
+        var me = this;
+        
+        if (me.url) {
+            me.initAPI();
+            me.connected = true;
+            me.fireEvent('connect', me);
+        } else if(!me.url) {
+            //&lt;debug&gt;
+            Ext.Error.raise('Error initializing RemotingProvider, no url configured.');
+            //&lt;/debug&gt;
+        }
+    },
+
+    // inherit docs
+    disconnect: function(){
+        var me = this;
+        
+        if (me.connected) {
+            me.connected = false;
+            me.fireEvent('disconnect', me);
+        }
+    },
+    
+<span id='Ext-direct-RemotingProvider-method-runCallback'>    /**
+</span>     * Run any callbacks related to the transaction.
+     * @private
+     * @param {Ext.direct.Transaction} transaction The transaction
+     * @param {Ext.direct.Event} event The event
+     */
+    runCallback: function(transaction, event){
+        var funcName = event.status ? 'success' : 'failure',
+            callback,
+            result;
+        
+        if (transaction &amp;&amp; transaction.callback) {
+            callback = transaction.callback;
+            result = Ext.isDefined(event.result) ? event.result : event.data;
+        
+            if (Ext.isFunction(callback)) {
+                callback(result, event);
+            } else {
+                Ext.callback(callback[funcName], callback.scope, [result, event]);
+                Ext.callback(callback.callback, callback.scope, [result, event]);
+            }
+        }
+    },
+    
+<span id='Ext-direct-RemotingProvider-method-onData'>    /**
+</span>     * React to the ajax request being completed
+     * @private
+     */
+    onData: function(options, success, response){
+        var me = this,
+            i = 0,
+            len,
+            events,
+            event,
+            transaction,
+            transactions;
+            
+        if (success) {
+            events = me.createEvents(response);
+            for (len = events.length; i &lt; len; ++i) {
+                event = events[i];
+                transaction = me.getTransaction(event);
+                me.fireEvent('data', me, event);
+                if (transaction) {
+                    me.runCallback(transaction, event, true);
+                    Ext.direct.Manager.removeTransaction(transaction);
+                }
+            }
+        } else {
+            transactions = [].concat(options.transaction);
+            for (len = transactions.length; i &lt; len; ++i) {
+                transaction = me.getTransaction(transactions[i]);
+                if (transaction &amp;&amp; transaction.retryCount &lt; me.maxRetries) {
+                    transaction.retry();
+                } else {
+                    event = Ext.create('Ext.direct.ExceptionEvent', {
+                        data: null,
+                        transaction: transaction,
+                        code: Ext.direct.Manager.self.exceptions.TRANSPORT,
+                        message: 'Unable to connect to the server.',
+                        xhr: response
+                    });
+                    me.fireEvent('data', me, event);
+                    if (transaction) {
+                        me.runCallback(transaction, event, false);
+                        Ext.direct.Manager.removeTransaction(transaction);
+                    }
+                }
+            }
+        }
+    },
+    
+<span id='Ext-direct-RemotingProvider-method-getTransaction'>    /**
+</span>     * Get transaction from XHR options
+     * @private
+     * @param {Object} options The options sent to the Ajax request
+     * @return {Ext.direct.Transaction} The transaction, null if not found
+     */
+    getTransaction: function(options){
+        return options &amp;&amp; options.tid ? Ext.direct.Manager.getTransaction(options.tid) : null;
+    },
+    
+<span id='Ext-direct-RemotingProvider-method-configureRequest'>    /**
+</span>     * Configure a direct request
+     * @private
+     * @param {String} action The action being executed
+     * @param {Object} method The being executed
+     */
+    configureRequest: function(action, method, args){
+        var me = this,
+            callData = method.getCallData(args),
+            data = callData.data, 
+            callback = callData.callback, 
+            scope = callData.scope,
+            transaction;
+
+        transaction = Ext.create('Ext.direct.Transaction', {
+            provider: me,
+            args: args,
+            action: action,
+            method: method.name,
+            data: data,
+            callback: scope &amp;&amp; Ext.isFunction(callback) ? Ext.Function.bind(callback, scope) : callback
+        });
+
+        if (me.fireEvent('beforecall', me, transaction, method) !== false) {
+            Ext.direct.Manager.addTransaction(transaction);
+            me.queueTransaction(transaction);
+            me.fireEvent('call', me, transaction, method);
+        }
+    },
+    
+<span id='Ext-direct-RemotingProvider-method-getCallData'>    /**
+</span>     * Gets the Ajax call info for a transaction
+     * @private
+     * @param {Ext.direct.Transaction} transaction The transaction
+     * @return {Object} The call params
+     */
+    getCallData: function(transaction){
+        return {
+            action: transaction.action,
+            method: transaction.method,
+            data: transaction.data,
+            type: 'rpc',
+            tid: transaction.id
+        };
+    },
+    
+<span id='Ext-direct-RemotingProvider-method-sendRequest'>    /**
+</span>     * Sends a request to the server
+     * @private
+     * @param {Object/Array} data The data to send
+     */
+    sendRequest : function(data){
+        var me = this,
+            request = {
+                url: me.url,
+                callback: me.onData,
+                scope: me,
+                transaction: data,
+                timeout: me.timeout
+            }, callData,
+            enableUrlEncode = me.enableUrlEncode,
+            i = 0,
+            len,
+            params;
+            
+
+        if (Ext.isArray(data)) {
+            callData = [];
+            for (len = data.length; i &lt; len; ++i) {
+                callData.push(me.getCallData(data[i]));
+            }
+        } else {
+            callData = me.getCallData(data);
+        }
+
+        if (enableUrlEncode) {
+            params = {};
+            params[Ext.isString(enableUrlEncode) ? enableUrlEncode : 'data'] = Ext.encode(callData);
+            request.params = params;
+        } else {
+            request.jsonData = callData;
+        }
+        Ext.Ajax.request(request);
+    },
+    
+<span id='Ext-direct-RemotingProvider-method-queueTransaction'>    /**
+</span>     * Add a new transaction to the queue
+     * @private
+     * @param {Ext.direct.Transaction} transaction The transaction
+     */
+    queueTransaction: function(transaction){
+        var me = this,
+            enableBuffer = me.enableBuffer;
+        
+        if (transaction.form) {
+            me.sendFormRequest(transaction);
+            return;
+        }
+        
+        me.callBuffer.push(transaction);
+        if (enableBuffer) {
+            if (!me.callTask) {
+                me.callTask = Ext.create('Ext.util.DelayedTask', me.combineAndSend, me);
+            }
+            me.callTask.delay(Ext.isNumber(enableBuffer) ? enableBuffer : 10);
+        } else {
+            me.combineAndSend();
+        }
+    },
+    
+<span id='Ext-direct-RemotingProvider-method-combineAndSend'>    /**
+</span>     * Combine any buffered requests and send them off
+     * @private
+     */
+    combineAndSend : function(){
+        var buffer = this.callBuffer,
+            len = buffer.length;
+            
+        if (len &gt; 0) {
+            this.sendRequest(len == 1 ? buffer[0] : buffer);
+            this.callBuffer = [];
+        }
+    },
+    
+<span id='Ext-direct-RemotingProvider-method-configureFormRequest'>    /**
+</span>     * Configure a form submission request
+     * @private
+     * @param {String} action The action being executed
+     * @param {Object} method The method being executed
+     * @param {HTMLElement} form The form being submitted
+     * @param {Function} callback (optional) A callback to run after the form submits
+     * @param {Object} scope (optional) A scope to execute the callback in
+     */
+    configureFormRequest : function(action, method, form, callback, scope){
+        var me = this,
+            transaction = Ext.create('Ext.direct.Transaction', {
+                provider: me,
+                action: action,
+                method: method.name,
+                args: [form, callback, scope],
+                callback: scope &amp;&amp; Ext.isFunction(callback) ? Ext.Function.bind(callback, scope) : callback,
+                isForm: true
+            }),
+            isUpload,
+            params;
+
+        if (me.fireEvent('beforecall', me, transaction, method) !== false) {
+            Ext.direct.Manager.addTransaction(transaction);
+            isUpload = String(form.getAttribute(&quot;enctype&quot;)).toLowerCase() == 'multipart/form-data';
+            
+            params = {
+                extTID: transaction.id,
+                extAction: action,
+                extMethod: method.name,
+                extType: 'rpc',
+                extUpload: String(isUpload)
+            };
+            
+            // change made from typeof callback check to callback.params
+            // to support addl param passing in DirectSubmit EAC 6/2
+            Ext.apply(transaction, {
+                form: Ext.getDom(form),
+                isUpload: isUpload,
+                params: callback &amp;&amp; Ext.isObject(callback.params) ? Ext.apply(params, callback.params) : params
+            });
+            me.fireEvent('call', me, transaction, method);
+            me.sendFormRequest(transaction);
+        }
+    },
+    
+<span id='Ext-direct-RemotingProvider-method-sendFormRequest'>    /**
+</span>     * Sends a form request
+     * @private
+     * @param {Ext.direct.Transaction} transaction The transaction to send
+     */
+    sendFormRequest: function(transaction){
+        Ext.Ajax.request({
+            url: this.url,
+            params: transaction.params,
+            callback: this.onData,
+            scope: this,
+            form: transaction.form,
+            isUpload: transaction.isUpload,
+            transaction: transaction
+        });
+    }
+    
+});
+</pre>
+</body>
+</html>