View Full Version : Dynamic Method Naming

06-17-2004, 11:23 PM
I'm trying to write a class which will encapsulate webservice consumption through javascript; there's not a lot on webservices at these fora. It's been a bit difficult, and I'm going forcibly bald.

In this article on Gecko webservice consumption (http://devedge.netscape.com/viewsource/2003/wsdl/01/), it's noted that the callback function for the 'listener' object that is used in the creation of the 'proxy' object has (understandably) a convention - methodnameCallback. In this class I take an argument which is the method name, among others:
function WebService (serviceURL, serviceName, methodName, responseHandler, errorHandler) {...}
When I try to assign that dynamically -inside this constructor-
var tmpName = methodName + 'Callback',
listener = {
onLoad : function (aProxy) {
proxy = aProxy;
onError : errorHandler
listener[tmpName] : responseHandler;
I get the following error in Firefox 0.9. on that last line. Error: invalid label There are no illegal characters in the passed argument, and there is no reason I can think of that I shouldn't be able to do this.

Has anybody else had any kind of difficulty?