| Package | com.esri.bacore.client |
| Class | public class BACommand |
| Inheritance | BACommand flash.events.EventDispatcher |
This class encapsulates an instance of a task together with task parameters.
The execution of task is suspended
until the execute method of this class is called. The unified interface of the BACommand class
allows user to prepare a batch task consisting of heterogeneous tasks.
This class can also be used for wrapping any asynchronous request
which returns control via methods of the IResponder interface instance.
Data objects returned with the fault and result methods of this interface
are converted by this command to FaultEvent and BATaskCompletedEvent
instances, respectively. See AbstractClient.NotifyOnFault method on details how a fault data
object is converted to FaultEvent. The result data object is converted to
BATaskCompletedEvent as follows: if it is an instance of this event,
a clone is created; otherwise, a new instance of the BATaskCompletedEvent
class is created with the result data as result and a value of the BACommand.taskName
property as a task name.
See also
| Property | Defined By | ||
|---|---|---|---|
| lastResult : * [read-only]
The last result of execution this command. | BACommand | ||
| name : String [read-only]
Command name. | BACommand | ||
| taskName : String [read-only]
Name of task to be executed. | BACommand | ||
| Method | Defined By | ||
|---|---|---|---|
BACommand(name:String, taskName:String, execute:Function)
Creates a new instance of the BACommand class. | BACommand | ||
execute(responder:IResponder = null):AsyncToken
Sends a request for execution a Community Analyst Task to Community Analyst HTTP (REST) Service. | BACommand | ||
| Event | Summary | Defined By | ||
|---|---|---|---|---|
| The fault event is dispatched when an asynchronous execution of BACommand fails. | BACommand | |||
| The taskCompleted event is dispatched upon successful completion of the BACommand asynchronous execution. | BACommand | |||
| lastResult | property |
lastResult:* [read-only] The last result of execution this command.
public function get lastResult():*| name | property |
name:String [read-only] Command name.
public function get name():String| taskName | property |
taskName:String [read-only] Name of task to be executed.
public function get taskName():String| BACommand | () | Constructor |
public function BACommand(name:String, taskName:String, execute:Function)Creates a new instance of the BACommand class.
The task executing function should have the following signature:
execute(responder:IResponder):
name:String — Command name.
| |
taskName:String — A name of task to be executed.
| |
execute:Function — A function executing the task.
|
| execute | () | method |
public function execute(responder:IResponder = null):AsyncTokenSends a request for execution a Community Analyst Task to Community Analyst HTTP (REST) Service.
A response can be received in two ways—in an optional
responder object passed in parameters
of this method and/or in listeners of fault and taskCompleted
events registered for this command.
The responder is notified first when a response is received and parsed.
Its fault method receives a parameter of the FaultEvent type and its
result method receives a parameter of the BATaskCompletedEvent type
whose result property contains the result object.
After that the received event is dispatched for listeners of this command.
If a response is succesfully received, the result is assigned to the
lastResult property of this command.
Parameters
responder:IResponder (default = null) — A responder to call on result or fault.
|
AsyncToken — Asynch token associated with the response.
|
| fault | Event |
mx.rpc.events.FaultEventmx.rpc.events.FaultEvent.FAULTThe fault event is dispatched when an asynchronous execution of BACommand fails.
| taskCompleted | Event |
com.esri.bacore.BATaskCompletedEventcom.esri.bacore.BATaskCompletedEvent.COMPLETEThe taskCompleted event is dispatched upon successful completion of the BACommand asynchronous execution.
The BATaskCompletedEvent.COMPLETE constant defines the value of thetype property of the event object for a taskCompleted event.
The properties of the event object have the following values:
| Property | Value |
|---|---|
babbles | false |
cancelable | false |
currentTarget | The Object that defines the event listener that handles the event. |
target | The BATask object that dispatched the event. This is an instance of a Community Analyst Task that was executed. |
taskName | Name of a Community Analyst Task that was executed. |
result | Task execution result object. |
messages | Optional array of TaskMessage objects received. |
The currentTarget and target properties are
specified after the event was dispatched. A responder object passed in parameters of
a Community Analyst Task execute method receives the event before it is dispatched.
var command:BACommand;
// Create BACommand here...
command.execute(new mx.rpc.Responder(result, fault));
// ...
private function result(event:BATaskCompletedEvent):void
{
// event.result value contains the result of execution the command.
// Specify actions to be applied on result ...
}
private function fault(event:FaultEvent):void
{
// Specify actions to be applied on fault ...
}