Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / docs / source / Manager2.html
index 0399f38..842703b 100644 (file)
@@ -1,71 +1,77 @@
-<!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-direct.Manager'>/**
-</span> * @class Ext.direct.Manager
- * &lt;p&gt;&lt;b&gt;&lt;u&gt;Overview&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
+<!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-Manager'>/**
+</span> * Ext.Direct aims to streamline communication between the client and server by providing a single interface that
+ * reduces the amount of common code typically required to validate data and handle returned data packets (reading data,
+ * error conditions, etc).
  *
- * &lt;p&gt;Ext.Direct aims to streamline communication between the client and server
- * by providing a single interface that reduces the amount of common code
- * typically required to validate data and handle returned data packets
- * (reading data, error conditions, etc).&lt;/p&gt;
+ * The Ext.direct namespace includes several classes for a closer integration with the server-side. The Ext.data
+ * namespace also includes classes for working with Ext.data.Stores which are backed by data from an Ext.Direct method.
  *
- * &lt;p&gt;The Ext.direct namespace includes several classes for a closer integration
- * with the server-side. The Ext.data namespace also includes classes for working
- * with Ext.data.Stores which are backed by data from an Ext.Direct method.&lt;/p&gt;
+ * # Specification
  *
- * &lt;p&gt;&lt;b&gt;&lt;u&gt;Specification&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
+ * For additional information consult the [Ext.Direct Specification][1].
  *
- * &lt;p&gt;For additional information consult the
- * &lt;a href=&quot;http://sencha.com/products/extjs/extdirect&quot;&gt;Ext.Direct Specification&lt;/a&gt;.&lt;/p&gt;
+ * # Providers
  *
- * &lt;p&gt;&lt;b&gt;&lt;u&gt;Providers&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
+ * Ext.Direct uses a provider architecture, where one or more providers are used to transport data to and from the
+ * server. There are several providers that exist in the core at the moment:
  *
- * &lt;p&gt;Ext.Direct uses a provider architecture, where one or more providers are
- * used to transport data to and from the server. There are several providers
- * that exist in the core at the moment:&lt;/p&gt;&lt;div class=&quot;mdetail-params&quot;&gt;&lt;ul&gt;
+ * - {@link Ext.direct.JsonProvider JsonProvider} for simple JSON operations
+ * - {@link Ext.direct.PollingProvider PollingProvider} for repeated requests
+ * - {@link Ext.direct.RemotingProvider RemotingProvider} exposes server side on the client.
  *
- * &lt;li&gt;{@link Ext.direct.JsonProvider JsonProvider} for simple JSON operations&lt;/li&gt;
- * &lt;li&gt;{@link Ext.direct.PollingProvider PollingProvider} for repeated requests&lt;/li&gt;
- * &lt;li&gt;{@link Ext.direct.RemotingProvider RemotingProvider} exposes server side
- * on the client.&lt;/li&gt;
- * &lt;/ul&gt;&lt;/div&gt;
+ * A provider does not need to be invoked directly, providers are added via {@link Ext.direct.Manager}.{@link #addProvider}.
  *
- * &lt;p&gt;A provider does not need to be invoked directly, providers are added via
- * {@link Ext.direct.Manager}.{@link Ext.direct.Manager#add add}.&lt;/p&gt;
+ * # Router
  *
- * &lt;p&gt;&lt;b&gt;&lt;u&gt;Router&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
+ * Ext.Direct utilizes a &quot;router&quot; on the server to direct requests from the client to the appropriate server-side
+ * method. Because the Ext.Direct API is completely platform-agnostic, you could completely swap out a Java based server
+ * solution and replace it with one that uses C# without changing the client side JavaScript at all.
  *
- * &lt;p&gt;Ext.Direct utilizes a &quot;router&quot; on the server to direct requests from the client
- * to the appropriate server-side method. Because the Ext.Direct API is completely
- * platform-agnostic, you could completely swap out a Java based server solution
- * and replace it with one that uses C# without changing the client side JavaScript
- * at all.&lt;/p&gt;
+ * # Server side events
  *
- * &lt;p&gt;&lt;b&gt;&lt;u&gt;Server side events&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
+ * Custom events from the server may be handled by the client by adding listeners, for example:
+ *
+ *     {&quot;type&quot;:&quot;event&quot;,&quot;name&quot;:&quot;message&quot;,&quot;data&quot;:&quot;Successfully polled at: 11:19:30 am&quot;}
+ *
+ *     // add a handler for a 'message' event sent by the server
+ *     Ext.direct.Manager.on('message', function(e){
+ *         out.append(String.format('&lt;p&gt;&lt;i&gt;{0}&lt;/i&gt;&lt;/p&gt;', e.data));
+ *         out.el.scrollTo('t', 100000, true);
+ *     });
+ *
+ *    [1]: http://sencha.com/products/extjs/extdirect
  *
- * &lt;p&gt;Custom events from the server may be handled by the client by adding
- * listeners, for example:&lt;/p&gt;
- * &lt;pre&gt;&lt;code&gt;
-{&quot;type&quot;:&quot;event&quot;,&quot;name&quot;:&quot;message&quot;,&quot;data&quot;:&quot;Successfully polled at: 11:19:30 am&quot;}
-
-// add a handler for a 'message' event sent by the server
-Ext.direct.Manager.on('message', function(e){
-    out.append(String.format('&amp;lt;p&gt;&amp;lt;i&gt;{0}&amp;lt;/i&gt;&amp;lt;/p&gt;', e.data));
-            out.el.scrollTo('t', 100000, true);
-});
- * &lt;/code&gt;&lt;/pre&gt;
  * @singleton
+ * @alternateClassName Ext.Direct
  */
-
 Ext.define('Ext.direct.Manager', {
-    
+
     /* Begin Definitions */
     singleton: true,
-   
+
     mixins: {
         observable: 'Ext.util.Observable'
     },
-    
+
     requires: ['Ext.util.MixedCollection'],
-    
+
     statics: {
         exceptions: {
             TRANSPORT: 'xhr',
@@ -74,74 +80,75 @@ Ext.define('Ext.direct.Manager', {
             SERVER: 'exception'
         }
     },
-    
+
     /* End Definitions */
-   
+
     constructor: function(){
         var me = this;
-       
+
         me.addEvents(
-<span id='Ext-direct.Manager-event-event'>            /**
+<span id='Ext-direct-Manager-event-event'>            /**
 </span>             * @event event
              * Fires after an event.
-             * @param {event} e The Ext.direct.Event type that occurred.
+             * @param {Ext.direct.Event} e The Ext.direct.Event type that occurred.
              * @param {Ext.direct.Provider} provider The {@link Ext.direct.Provider Provider}.
              */
             'event',
-<span id='Ext-direct.Manager-event-exception'>            /**
+<span id='Ext-direct-Manager-event-exception'>            /**
 </span>             * @event exception
              * Fires after an event exception.
-             * @param {event} e The Ext.direct.Event type that occurred.
+             * @param {Ext.direct.Event} e The event type that occurred.
              */
             'exception'
         );
         me.transactions = Ext.create('Ext.util.MixedCollection');
         me.providers = Ext.create('Ext.util.MixedCollection');
-        
+
         me.mixins.observable.constructor.call(me);
     },
-    
-<span id='Ext-direct.Manager-method-addProvider'>    /**
-</span>     * Adds an Ext.Direct Provider and creates the proxy or stub methods to execute server-side methods.
-     * If the provider is not already connected, it will auto-connect.
-     * &lt;pre&gt;&lt;code&gt;
-var pollProv = new Ext.direct.PollingProvider({
-    url: 'php/poll2.php'
-});
 
-Ext.direct.Manager.addProvider({
-    &quot;type&quot;:&quot;remoting&quot;,       // create a {@link Ext.direct.RemotingProvider}
-    &quot;url&quot;:&quot;php\/router.php&quot;, // url to connect to the Ext.Direct server-side router.
-    &quot;actions&quot;:{              // each property within the actions object represents a Class
-        &quot;TestAction&quot;:[       // array of methods within each server side Class
-        {
-            &quot;name&quot;:&quot;doEcho&quot;, // name of method
-            &quot;len&quot;:1
-        },{
-            &quot;name&quot;:&quot;multiply&quot;,
-            &quot;len&quot;:1
-        },{
-            &quot;name&quot;:&quot;doForm&quot;,
-            &quot;formHandler&quot;:true, // handle form on server with Ext.Direct.Transaction
-            &quot;len&quot;:1
-        }]
-    },
-    &quot;namespace&quot;:&quot;myApplication&quot;,// namespace to create the Remoting Provider in
-},{
-    type: 'polling', // create a {@link Ext.direct.PollingProvider}
-    url:  'php/poll.php'
-}, pollProv); // reference to previously created instance
-     * &lt;/code&gt;&lt;/pre&gt;
-     * @param {Object/Array} provider Accepts either an Array of Provider descriptions (an instance
-     * or config object for a Provider) or any number of Provider descriptions as arguments.  Each
-     * Provider description instructs Ext.Direct how to create client-side stub methods.
+<span id='Ext-direct-Manager-method-addProvider'>    /**
+</span>     * Adds an Ext.Direct Provider and creates the proxy or stub methods to execute server-side methods. If the provider
+     * is not already connected, it will auto-connect.
+     *
+     *     var pollProv = new Ext.direct.PollingProvider({
+     *         url: 'php/poll2.php'
+     *     });
+     *
+     *     Ext.direct.Manager.addProvider({
+     *         &quot;type&quot;:&quot;remoting&quot;,       // create a {@link Ext.direct.RemotingProvider}
+     *         &quot;url&quot;:&quot;php\/router.php&quot;, // url to connect to the Ext.Direct server-side router.
+     *         &quot;actions&quot;:{              // each property within the actions object represents a Class
+     *             &quot;TestAction&quot;:[       // array of methods within each server side Class
+     *             {
+     *                 &quot;name&quot;:&quot;doEcho&quot;, // name of method
+     *                 &quot;len&quot;:1
+     *             },{
+     *                 &quot;name&quot;:&quot;multiply&quot;,
+     *                 &quot;len&quot;:1
+     *             },{
+     *                 &quot;name&quot;:&quot;doForm&quot;,
+     *                 &quot;formHandler&quot;:true, // handle form on server with Ext.Direct.Transaction
+     *                 &quot;len&quot;:1
+     *             }]
+     *         },
+     *         &quot;namespace&quot;:&quot;myApplication&quot;,// namespace to create the Remoting Provider in
+     *     },{
+     *         type: 'polling', // create a {@link Ext.direct.PollingProvider}
+     *         url:  'php/poll.php'
+     *     }, pollProv); // reference to previously created instance
+     *
+     * @param {Ext.direct.Provider/Object...} provider
+     * Accepts any number of Provider descriptions (an instance or config object for
+     * a Provider). Each Provider description instructs Ext.Directhow to create
+     * client-side stub methods.
      */
     addProvider : function(provider){
         var me = this,
             args = arguments,
             i = 0,
             len;
-            
+
         if (args.length &gt; 1) {
             for (len = args.length; i &lt; len; ++i) {
                 me.addProvider(args[i]);
@@ -163,27 +170,27 @@ Ext.direct.Manager.addProvider({
 
         return provider;
     },
-    
-<span id='Ext-direct.Manager-method-getProvider'>    /**
-</span>     * Retrieve a {@link Ext.direct.Provider provider} by the
-     * &lt;b&gt;&lt;tt&gt;{@link Ext.direct.Provider#id id}&lt;/tt&gt;&lt;/b&gt; specified when the provider is
-     * {@link #addProvider added}.
-     * @param {String/Ext.data.Provider} id The id of the provider, or the provider instance.
+
+<span id='Ext-direct-Manager-method-getProvider'>    /**
+</span>     * Retrieves a {@link Ext.direct.Provider provider} by the **{@link Ext.direct.Provider#id id}** specified when the
+     * provider is {@link #addProvider added}.
+     * @param {String/Ext.direct.Provider} id The id of the provider, or the provider instance.
      */
     getProvider : function(id){
         return id.isProvider ? id : this.providers.get(id);
     },
-    
-<span id='Ext-direct.Manager-method-removeProvider'>    /**
+
+<span id='Ext-direct-Manager-method-removeProvider'>    /**
 </span>     * Removes the provider.
      * @param {String/Ext.direct.Provider} provider The provider instance or the id of the provider.
      * @return {Ext.direct.Provider} The provider, null if not found.
      */
     removeProvider : function(provider){
         var me = this,
-            providers = me.providers,
-            provider = provider.isProvider ? provider : providers.get(provider);
-            
+            providers = me.providers;
+
+        provider = provider.isProvider ? provider : providers.get(provider);
+
         if (provider) {
             provider.un('data', me.onProviderData, me);
             providers.remove(provider);
@@ -191,9 +198,9 @@ Ext.direct.Manager.addProvider({
         }
         return null;
     },
-    
-<span id='Ext-direct.Manager-method-addTransaction'>    /**
-</span>     * Add a transaction to the manager.
+
+<span id='Ext-direct-Manager-method-addTransaction'>    /**
+</span>     * Adds a transaction to the manager.
      * @private
      * @param {Ext.direct.Transaction} transaction The transaction to add
      * @return {Ext.direct.Transaction} transaction
@@ -203,8 +210,8 @@ Ext.direct.Manager.addProvider({
         return transaction;
     },
 
-<span id='Ext-direct.Manager-method-removeTransaction'>    /**
-</span>     * Remove a transaction from the manager.
+<span id='Ext-direct-Manager-method-removeTransaction'>    /**
+</span>     * Removes a transaction from the manager.
      * @private
      * @param {String/Ext.direct.Transaction} transaction The transaction/id of transaction to remove
      * @return {Ext.direct.Transaction} transaction
@@ -215,7 +222,7 @@ Ext.direct.Manager.addProvider({
         return transaction;
     },
 
-<span id='Ext-direct.Manager-method-getTransaction'>    /**
+<span id='Ext-direct-Manager-method-getTransaction'>    /**
 </span>     * Gets a transaction
      * @private
      * @param {String/Ext.direct.Transaction} transaction The transaction/id of transaction to get
@@ -224,12 +231,12 @@ Ext.direct.Manager.addProvider({
     getTransaction: function(transaction){
         return transaction.isTransaction ? transaction : this.transactions.get(transaction);
     },
-    
+
     onProviderData : function(provider, event){
         var me = this,
             i = 0,
             len;
-            
+
         if (Ext.isArray(event)) {
             for (len = event.length; i &lt; len; ++i) {
                 me.onProviderData(provider, event[i]);
@@ -238,7 +245,7 @@ Ext.direct.Manager.addProvider({
         }
         if (event.name &amp;&amp; event.name != 'event' &amp;&amp; event.name != 'exception') {
             me.fireEvent(event.name, event);
-        } else if (event.type == 'exception') {
+        } else if (event.status === false) {
             me.fireEvent('exception', event);
         }
         me.fireEvent('event', event, provider);
@@ -247,4 +254,6 @@ Ext.direct.Manager.addProvider({
     // Backwards compatibility
     Ext.Direct = Ext.direct.Manager;
 });
-</pre></pre></body></html>
\ No newline at end of file
+</pre>
+</body>
+</html>