com.smartgwt.client.util.workflow
Class ScriptTask

java.lang.Object
  extended by com.smartgwt.client.core.BaseClass
      extended by com.smartgwt.client.util.workflow.ProcessElement
          extended by com.smartgwt.client.util.workflow.Task
              extended by com.smartgwt.client.util.workflow.ScriptTask

public class ScriptTask
extends Task

Task that executes arbitrary code, either synchronous or asynchronous. Override the execute method to provide custom logic.


Field Summary
 
Fields inherited from class com.smartgwt.client.core.BaseClass
config, id, scClassName
 
Constructor Summary
ScriptTask()
           
ScriptTask(JavaScriptObject jsObj)
           
ScriptTask(String ID)
           
ScriptTask(String ID, ProcessElement nextElement)
           
ScriptTask(String ID, String nextElement)
           
 
Method Summary
 JavaScriptObject create()
           
 Object execute(Object input, Record inputRecord)
          Execute the task.
 Object getInputData()
          Get the inputs to this task as specified by inputField.
 Record getInputRecord()
          Get all inputs to the task as specified by the inputFieldList, as a Record.
 Boolean getIsAsync()
          Whether the script task is asynchronous.
static ScriptTask getOrCreateRef(JavaScriptObject jsObj)
           
protected  void onInit_ScriptTask()
           
protected  void onInit()
           
 void setIsAsync(Boolean isAsync)
          Whether the script task is asynchronous.
 void setJavaScriptObject(JavaScriptObject jsObj)
           
 void setOutputData(Object taskOutput)
          Set the task output as specified by outputField.
 void setOutputRecord(Record outputRecord)
          Set all outputs of the task as specified by the outputFieldList, by providing a Record.
 
Methods inherited from class com.smartgwt.client.util.workflow.Task
getInputField, getInputFields, getOutputField, getOutputFields, setInputField, setInputFields, setOutputField, setOutputFields
 
Methods inherited from class com.smartgwt.client.util.workflow.ProcessElement
convertToJavaScriptArray, getID, getJsObj, getNextElement, getOrCreateJsObj, getProcessElements, isCreated, setAttribute, setID, setNextElement
 
Methods inherited from class com.smartgwt.client.core.BaseClass
destroy, doAddHandler, error, error, errorIfNotCreated, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsElement, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAttributeAsMap, getAttributeAsString, getAttributeAsStringArray, getConfig, getHandlerCount, getRef, getScClassName, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setProperty, setProperty, setProperty, setProperty, setScClassName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScriptTask

public ScriptTask()

ScriptTask

public ScriptTask(JavaScriptObject jsObj)

ScriptTask

public ScriptTask(String ID)

ScriptTask

public ScriptTask(String ID,
                  String nextElement)

ScriptTask

public ScriptTask(String ID,
                  ProcessElement nextElement)
Method Detail

getOrCreateRef

public static ScriptTask getOrCreateRef(JavaScriptObject jsObj)

setJavaScriptObject

public void setJavaScriptObject(JavaScriptObject jsObj)
Overrides:
setJavaScriptObject in class Task

create

public JavaScriptObject create()
Overrides:
create in class Task

setIsAsync

public void setIsAsync(Boolean isAsync)
                throws IllegalStateException
Whether the script task is asynchronous. A synchronous task is expected to return data directly from execute() and is considered complete once the execute() method exits.

An asnychronous task is expected to start processing in execute(), and will not be considered complete until either ScriptTask.setOutputData or ScriptTask.setOutputRecord is called.

Parameters:
isAsync - isAsync Default value is false
Throws:
IllegalStateException - this property cannot be changed after the underlying component has been created

getIsAsync

public Boolean getIsAsync()
Whether the script task is asynchronous. A synchronous task is expected to return data directly from execute() and is considered complete once the execute() method exits.

An asnychronous task is expected to start processing in execute(), and will not be considered complete until either ScriptTask.setOutputData or ScriptTask.setOutputRecord is called.

Returns:
Boolean

execute

public Object execute(Object input,
                      Record inputRecord)
Execute the task.

Parameters:
input - the task input
inputRecord - the task input record if an inputFieldList was specified. See TaskIO
Returns:
the task output. For multiple field output, call ScriptTask.setOutputRecord instead, and return null

getInputData

public Object getInputData()
Get the inputs to this task as specified by inputField.

For a task with a inputFieldList, use ScriptTask.getInputRecord to get access to other inputs.

Returns:
input data
See Also:
TaskIO overview and related methods

getInputRecord

public Record getInputRecord()
Get all inputs to the task as specified by the inputFieldList, as a Record.

Returns:
input data
See Also:
TaskIO overview and related methods

setOutputRecord

public void setOutputRecord(Record outputRecord)
Set all outputs of the task as specified by the outputFieldList, by providing a Record.

Parameters:
outputRecord - output record

setOutputData

public void setOutputData(Object taskOutput)
Set the task output as specified by outputField.

NOTE: for an asychronous task, calling setOutputData() indicates the task is complete. For a task with multiple outputs, call ScriptTask.setOutputRecord instead.

Parameters:
taskOutput - task output

onInit_ScriptTask

protected void onInit_ScriptTask()

onInit

protected void onInit()
Overrides:
onInit in class BaseClass