views:

249

answers:

1

Flex3 + Cairngorm. I have my service in Servicis.mxml:

<mx:HTTPService id="docIndex" url="{URL_PREFIX}/jobs/{???}/docs" resultFormat="e4x"/>

And I call it from my generic restful delegate like this:

public function index(params:Object):void {
  var call:AsyncToken = services.getHTTPService(resourceName+"Index").send(params);
  call.addResponder(responder);
 }

I want to know how I can use the params Object I pass inside the url definition (the ??? above). And please tell me how you would go about searching an answer to this in the documentation, I'd like to be a little more independet on these problems...

EDIT: I'll explain myself if you didn't understand my problem: I have a restful api written in rails to which I'm connecting. Doc is a child resource of Job. If I want to get all docs I have to supply a job_id too. Therefore in the service the url must be changed for each .send() call, with the proper job_id (the ??? part above). I'd like to call it like myDelegate.index({job_id:34}) and insert that job_id field in the Service URL.

A: 

Write a class that extends HTTPService and allows you to set parameters into the url. Then, in your index function you can fetch it with services.getHTTPService, and call a function you create that sets the url values for you.

In your service locator create an instance of your class rather than a flat HTTPService.

Sean Clark Hess
I'll try.. do you think that getHTTPService will work even with my child class?
luca
Yes, it should, because your http service is still an HTTPService
Sean Clark Hess