This does what I'd expect:
var orig = OpenLayers.Protocol.WFS.v1.prototype.handleRead;
OpenLayers.Util.extend(OpenLayers.Protocol.WFS.v1.prototype, {
handleRead: function(response, options) {
alert("handleRead");
orig.apply(this, arguments);
}
});
Does it for you?
Tim
On 6/30/11 3:39 PM, myOpenLayersUName wrote:
Hi Tim,
Thank you for your response. Yes, I was able to get your simple case to
work. Further, I was able to load this:
OpenLayers.Util.extend(OpenLayers.Protocol.WFS.v1.prototype, {
foo: "bar"
,blah: function(){
alert(this.foo);
}
});
And, within the real OpenLayers.Protocol.WFS.v1.handleRead function, I added
a call to this.blah() and at runtime, the alert with "bar" appeared.
However, when I try to override an existing function I don't seem able to do
it.
Continuing with my example above, if I removed the this.blah() call that I
added in the real OpenLayers.Protocol.WFS.v1.handleRead function (so it's
back to its distribution form) and updated my own file as follows:
OpenLayers.Util.extend(OpenLayers.Protocol.WFS.v1.prototype, {
foo: "bar"
,blah: function(){
alert(this.foo);
}
,handleRead: function(response, options) {
this.blah();
if(options.callback) {
var request = response.priv;
if(request.status>= 200&& request.status< 300) {
// success
response.features = this.parseFeatures(request);
response.code = OpenLayers.Protocol.Response.SUCCESS;
} else {
// failure
response.code = OpenLayers.Protocol.Response.FAILURE;
}
options.callback.call(options.scope, response);
};
}
});
At runtime, my handleRead is not run and I don't see the alert with "bar" in
it.
When I step through the OpenLayers.Util.extend function, it sure looks like
my handleRead is overwriting the distributed one but at runtime it's
definitely not using it.
I really don't get what the problem could be here.
--
View this message in context:
http://osgeo-org.1803224.n2.nabble.com/How-to-override-abstract-OpenLayers-Protocol-WFS-v1-tp6534072p6535084.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.
_______________________________________________
Dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
--
Tim Schaub
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.
_______________________________________________
Dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev