Packagecom.esri.bacore.client
Classpublic class BACommand
InheritanceBACommand Inheritance flash.events.EventDispatcher

The BACommand class provides the unified execution of a Community Analyst Task.

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.

View the examples

See also

BatchTaskParameters


Public Properties
 PropertyDefined 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
Public Methods
 MethodDefined 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
Events
 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
Property Detail
lastResultproperty
lastResult:*  [read-only]

The last result of execution this command.


Implementation
    public function get lastResult():*
nameproperty 
name:String  [read-only]

Command name.


Implementation
    public function get name():String
taskNameproperty 
taskName:String  [read-only]

Name of task to be executed.


Implementation
    public function get taskName():String
Constructor Detail
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):

Parameters
name:String — Command name.
 
taskName:String — A name of task to be executed.
 
execute:Function — A function executing the task.
Method Detail
execute()method
public function execute(responder:IResponder = null):AsyncToken

Sends 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.

Returns
AsyncToken — Asynch token associated with the response.
Event Detail
fault Event
Event Object Type: mx.rpc.events.FaultEvent
FaultEvent.type property = mx.rpc.events.FaultEvent.FAULT

The fault event is dispatched when an asynchronous execution of BACommand fails.

taskCompleted Event  
Event Object Type: com.esri.bacore.BATaskCompletedEvent
BATaskCompletedEvent.type property = com.esri.bacore.BATaskCompletedEvent.COMPLETE

The taskCompleted event is dispatched upon successful completion of the BACommand asynchronous execution.

The BATaskCompletedEvent.COMPLETE constant defines the value of the type property of the event object for a taskCompleted event.

The properties of the event object have the following values:

PropertyValue
babblesfalse
cancelablefalse
currentTargetThe Object that defines the event listener that handles the event.
targetThe BATask object that dispatched the event. This is an instance of a Community Analyst Task that was executed.
taskNameName of a Community Analyst Task that was executed.
resultTask execution result object.
messagesOptional 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.

Examples
The code snippet below shows how to execute a BACommand instance using a responder.
     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 ...
     }