[Helma-user] static methods of Prototype
Hannes Wallnoefer
hannesw at gmail.com
Thu Aug 10 17:04:23 CEST 2006
Hi Anton,
2006/8/10, Anton Pirker <helma at gmiatlich.net>:
> Hi list!
>
> I want to have a static method for a Prototype. So i can call the method
> without a HopObject of the Prototype.
> For example:
>
> var s = MyProtoName.getStuff();
This should do:
MyProtoName.getStuff = function() {
...
};
>
> The second thing is, that i only have a string containing the name of
> the prototype. Can i get the Prototype from the string somehow?
>
> Something like this:
>
> var s = "MyProtoName";
> var proto = new MagicStuff(s);
> proto.getStuff();
You should be able to get the prototype constructor via
global[s]
(global is a reference to the global object).
You should be able to invoke the constructor via
new global[s]();
hope this works/helps
hannes
More information about the Helma-user
mailing list