View Full Version : Access to variable (static) by resource name, reflection

29 Aug 2014, 4:06 AM
Hi all,

I think this is a very simple issue, but I don't really know how to address it.

I have defined a class called Networking were I keep all the networking tools within my app, included resources as the URLS.

So I have defined some statics fields, as for example:

statics : {
URL_DOMAIN: 'https://domainName.com',
URL_REQUEST1: '/restServices/request1',
URL_REQUEST2: '/restServices/request2',

and a function

getResourceURL: function (ResourceName){

return (this.self.URL_DOMAIN + this.self.ResourceName);

And obviously getResourceURL throws an error, because I can't access with the ResourceName to the static fields. My idea would be to pass URL_REQUEST1 as a ResourceName, and then combine the URL domanin with the specific resourse and return that string.

Any ideas on how could I adress this problem?

Thanks in advance for any suggestions!

29 Aug 2014, 4:28 AM
This is the JavaScript basics. Walking, where using ExtJS is the equivalent of running.

getResourceURL: function (resourceName){

return (this.self.URL_DOMAIN + this.self[resourceName]);

You should not capitalize variables. Only class names.