(This tag must be placed inside an <EventHandlers> tag or a <MessageHandlers> tag)
The RemoteObjectInvoker tag is used to create a Remote Object instance and call a method on the object created. To use this tag, you need to specify the same attributes you would when creating a remote object with the <mx:RemoteObject> tag. In addition, you need to specify what method to call. This tag will also accept all mx.rpc.remoting.RemoteObject tag attributes (with the exception of the "operations" property).
<RemoteObjectInvoker destination="YourDestination" source="path.to.your.service" method="methodToCall" arguments="{['argument1', 'argument2']}" />
The above example would be the same as doing the following:
<mx:RemoteObject id="myService"
destination="ColdFusion"
source="path.to.this.service" />
myService.methodToCall('argument1', 'argument2');
You would also need to either create event handlers for the server result and fault or create a Responder to handle them. That is not necessary when using the RemoteObjectInvoker tag because results and faults are handled by Mate. See section "Handling a service result or fault".
With this tag, you can also utilize an already created RemoteObject instance. This is useful when the same services are used by several EventHandlers blocks or several EventMaps.
Suppose you have a Remote Object tag (either in the event map itself or in a different file):
<mx:RemoteObject id="myService" destination="ColdFusion" source="path.to.this.service" />
You can call a method on that already created service as follows:
<RemoteObjectInvoker instance="{myService}" method="methodToCall" arguments="{['argument1', 'argument2']}" />
See the best practices for this tag
Attributes
method
required
The method attribute specifies what function to call on the remote object instance.
arguments
If the remote method has arguments, you can pass them via the "arguments" attribute.
Suppose you have a RemoteObject method called getPhotos and it expects a user name and an album name as arguments. You can specify them with the arguments attribute:
<RemoteObjectInvoker destination="YourDestination" source="path.to.your.service" method="getPhotos" arguments="{['Tom','My Album']}" />
Note that the arguments attribute expects an array. Besides passing literal values, you can pass values coming from the event that triggered the list execution:
<RemoteObjectInvoker destination="YourDestination" source="path.to.your.service" method="getPhotos" arguments="{[event.userName, event.album]}"/>
This assumes that the event contained a userName property and an album property.
You can also pass the complete data or lastReturn as an argument depending on what your service expects.
<RemoteObjectInvoker destination="YourDestination" source="path.to.your.service" method="getPhotos" arguments="{data}"/>
<RemoteObjectInvoker destination="YourDestination" source="path.to.your.service" method="getPhotos" arguments="{lastReturn}"/>
Of course you can use any combination of arguments:
<RemoteObjectInvoker destination="YourDestination" source="path.to.your.service" method="getPhotos" arguments="{[event.age, lastReturn, 'Tom']}"/>
instance
A RemoteObject instance
The instance attribute specifies the already created service instance to use to make the call. This attribute must be supplied using bindings because it needs to point to an already created object.
Suppose you have a RemoteObject already created:
<mx:RemoteObject id="myService" destination="ColdFusion" source="path.to.this.service" />
You can make a call to this service by using the RemoteObjectInvoker tag, with instance {myService}. Note that any property you need for your service must be defined in the RemoteObject tag.
<RemoteObjectInvoker instance="{myService}" />
debug
Boolean
Whether to show debugging information for this RemoteObject resultHandlers and faultHandlers. If true, Console output will show debugging information as those handlers run.
Inner tags
resultHandlers
A set of handlers to run when the server call returns a result. Inside this inner tag, you can use the same tags you would in the main body of an <EventHandlers> block, including other service calls.
faultHandlers
A set of handlers to run when the server call returns a fault. Inside this inner tag, you can use the same tags you would in the main body of an <EventHandlers>, including other service calls.
Handling a service result or fault
You can have a resultHandlers block and a faultHandlers block inside the tag to handle service results and faults.
<RemoteObjectInvoker destination="YourDestination" source="path.to.your.service" method="methodToCall" arguments="{['argument1', 'argument2']}"> <resultHandlers> ... this list executes when server returns results ... </resultHandlers> <faultHandlers> ... this list executes when server returns an error ... </faultHandlers> </RemoteObjectInvoker>
See "Handling a service result or fault" for more information.
I'm experimenting with converting a Cairngorm application over to Mate, not having much luck since I'm also very new to Cairngorm. However, i've hit a snag with SetCredentials()
Is SetCredentials() supported by MATE on remote object calls? If it is, can you point me in the right direction please.
Many thanks,
Matt Law