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);