From 23d24518fbf09c8f8fe225a9b0c1b0a5e874f7a0 Mon Sep 17 00:00:00 2001 From: bartvde Date: Mon, 7 Mar 2011 15:40:37 +0000 Subject: [PATCH] need a setFeatureType function on Protocol.WFS, r=erilem (closes #2639) git-svn-id: http://svn.openlayers.org/trunk/openlayers@11659 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Protocol/WFS/v1.js | 12 ++++++++++++ tests/Protocol/WFS.html | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/lib/OpenLayers/Protocol/WFS/v1.js b/lib/OpenLayers/Protocol/WFS/v1.js index 98258c54f5..7c8445cafb 100644 --- a/lib/OpenLayers/Protocol/WFS/v1.js +++ b/lib/OpenLayers/Protocol/WFS/v1.js @@ -183,6 +183,18 @@ OpenLayers.Protocol.WFS.v1 = OpenLayers.Class(OpenLayers.Protocol, { return response; }, + + /** + * APIMethod: setFeatureType + * Change the feature type on the fly. + * + * Parameters: + * featureType - {String} Local (without prefix) feature typeName. + */ + setFeatureType: function(featureType) { + this.featureType = featureType; + this.format.featureType = featureType; + }, /** * Method: handleRead diff --git a/tests/Protocol/WFS.html b/tests/Protocol/WFS.html index 5aa3cbca04..2945e5052d 100644 --- a/tests/Protocol/WFS.html +++ b/tests/Protocol/WFS.html @@ -24,6 +24,22 @@ "initialize returns instance of custom versioned protocol") } + function test_setFeatureType(t) { + t.plan(4); + var protocol = new OpenLayers.Protocol.WFS({ + url: "http://some.url.org", + featureNS: "http://namespace.org", + featureType: "type" + }); + t.eq(protocol.featureType, "type", "featureType set correctly by constructor"); + t.eq(protocol.format.featureType, "type", "featureType correctly set on format by constructor"); + // change the feature type on the fly + protocol.setFeatureType("foo"); + t.eq(protocol.featureType, "foo", "featureType changed correctly by setFeatureType"); + t.eq(protocol.format.featureType, "foo", "featureType correctly changed on format by setFeatureType"); + protocol.destroy(); + } + function test_read(t) { t.plan(7);