Page 1 of 1

Run Restservice with dynamic name

Posted: Thu Oct 25, 2012 10:41 pm
by Emmz

Hey gang..

I have a rest service defined in Tiggzi named. "test1"

I need to Invoke this Service using JS.
test1.execute({});
This is fine.
But I want to have the name of service to execute dynamic.
I tried..
var myservice = "test1";
myservice.execute({})
But get error TypeError: Object Service1 has no method 'execute'

Can U help?
Tks


Run Restservice with dynamic name

Posted: Thu Oct 25, 2012 10:50 pm
by maxkatz

No, that will not work because 'myservice' is a string in your code. It's possible to do that.. but a lot more involved. Export the source and see how we do it when you define a sample service.


Run Restservice with dynamic name

Posted: Fri Oct 26, 2012 1:57 am
by Emmz

I see...
execute: function(settings) {
settings = this.__buildRequestSettings(settings);
this.service.process(settings);
},
Working with this is way over my head.. lol

I will just send the service name with the data as array on a call function.
Split to get service name then check for name match then use the static myservice.execute({})

Thanks again Max...


Run Restservice with dynamic name

Posted: Fri Oct 26, 2012 12:03 pm
by Emmz

Went with the dreaded eval().....
Made array. Put myservice.execute({}); as item 0.
Called my Function that processes all My Rest Services.
Saves to LocalStorage.
Split out item[0]
string = theArray[0];
eval(string);

Works GREAT ..