[Commits] r1844 - in core/trunk/geoext: lib/GeoExt/data tests/lib/GeoExt/data

commits at geoext.org commits at geoext.org
Sat Jan 30 12:56:58 CET 2010


Author: bartvde
Date: 2010-01-30 12:56:58 +0100 (Sat, 30 Jan 2010)
New Revision: 1844

Modified:
   core/trunk/geoext/lib/GeoExt/data/ProtocolProxy.js
   core/trunk/geoext/tests/lib/GeoExt/data/ProtocolProxy.html
Log:
add an option to ProtocolProxy to set params as options, r=elemoine (closes #211)

Modified: core/trunk/geoext/lib/GeoExt/data/ProtocolProxy.js
===================================================================
--- core/trunk/geoext/lib/GeoExt/data/ProtocolProxy.js	2010-01-29 20:13:33 UTC (rev 1843)
+++ core/trunk/geoext/lib/GeoExt/data/ProtocolProxy.js	2010-01-30 11:56:58 UTC (rev 1844)
@@ -37,6 +37,13 @@
      */
     abortPrevious: true,
 
+    /** api: config[setParamsAsOptions]
+     *  ``Boolean``
+     *  Should options.params be set directly on options before passing it into
+     *  the protocol's read method? Default is ``false``.
+     */
+    setParamsAsOptions: false,
+
     /** private: property[response]
      *  ``OpenLayers.Protocol.Response``
      *  The response returned by the read call on the protocol.
@@ -79,6 +86,10 @@
                 scope: this
             };
             Ext.applyIf(options, arg);
+            if (this.setParamsAsOptions === true) {
+                Ext.applyIf(options, options.params);
+                delete options.params;
+            }
             this.response = this.protocol.read(options);
         } else {
            callback.call(scope || this, null, arg, false);

Modified: core/trunk/geoext/tests/lib/GeoExt/data/ProtocolProxy.html
===================================================================
--- core/trunk/geoext/tests/lib/GeoExt/data/ProtocolProxy.html	2010-01-29 20:13:33 UTC (rev 1843)
+++ core/trunk/geoext/tests/lib/GeoExt/data/ProtocolProxy.html	2010-01-30 11:56:58 UTC (rev 1844)
@@ -90,6 +90,23 @@
             proxy.load(); // abort not called because proxy.abortPrevious is false
         }
 
+        function test_setParamsAsOptions(t) {
+            t.plan(2);
+            var params = {fake: "params"};
+            protocol = new OpenLayers.Protocol({
+                read: function(o) {
+                    t.eq(o.fake, params.fake,
+                         "protocol read is passed expected params directly");
+                    t.eq(o.params, undefined, "Params is cleared");
+                }
+            });
+            var proxy = new GeoExt.data.ProtocolProxy({
+                setParamsAsOptions: true,
+                protocol: protocol
+            });
+            proxy.load(params);
+        }
+
     </script>
 
   <body>



More information about the Commits mailing list