Class ScriptTask
- All Implemented Interfaces:
HasHandlers
- Direct Known Subclasses:
StartProcessTask
execute() method to provide custom logic.- See Also:
-
Field Summary
Fields inherited from class com.smartgwt.client.core.BaseClass
config, configOnly, factoryCreated, factoryProperties, id, scClassName -
Constructor Summary
ConstructorsConstructorDescriptionScriptTask(JavaScriptObject jsObj) ScriptTask(String ID) ScriptTask(String ID, ProcessElement nextElement) ScriptTask(String ID, String nextElement) -
Method Summary
Modifier and TypeMethodDescriptioncreate()Execute the task.Comma-separated list of DataSource IDs to pre-load into the server-side scripting context before this task executes.Whether the script task is asynchronous.Scripting language for theexecute()body.static ScriptTaskgetOrCreateRef(JavaScriptObject jsObj) Does this processElement pass through output from the last executed task (i.e.protected voidonInit()protected voidsetDataSources(String dataSources) Comma-separated list of DataSource IDs to pre-load into the server-side scripting context before this task executes.setIsAsync(Boolean isAsync) Whether the script task is asynchronous.setLanguage(String language) Scripting language for theexecute()body.voidSets the task output available to the next task viaProcess.getLastTaskOutput()or more commonly, with aTaskInputExpressionproperty.voidSets the task output available to the next task viaProcess.getLastTaskOutput()or more commonly, with aTaskInputExpressionproperty.voidsetOutputData(Object taskOutput) Set the task output as specified byoutputField.setPassThruOutput(Boolean passThruOutput) Does this processElement pass through output from the last executed task (i.e.Methods inherited from class com.smartgwt.client.util.workflow.Task
getExpressionValue, getInputFieldList, getInputRecord, getInputs, getInputsAsString, getInputsAsStringArray, getOutputExpression, getOutputField, getOutputFieldList, getState, getStrictPaths, setInputFieldList, setInputs, setInputs, setInputs, setOutputExpression, setOutputField, setOutputFieldList, setState, setStrictPathsMethods inherited from class com.smartgwt.client.util.workflow.ProcessElement
completeElement, convertToJavaScriptArray, executeElement, getBindOutput, getClassDescription, getComponentReferences, getCurrentProcess, getDescription, getDynamicValue, getEditorType, getElementDescription, getForceSingle, getID, getInvalidTaskMessage, getJsObj, getMockMode, getNextElement, getOrCreateJsObj, getProcessElements, getSupportsMultipleInputRecords, getTextFormulaValue, getTypeTitle, getUndefinedComponentMessage, getUnresolvedComponentMessage, getWaitDuration, getWaitFor, getWaitLocator, isCreated, isValid, objectReferencesLastTaskOutput, reset, setAttribute, setBindOutput, setClassDescription, setCurrentProcess, setDescription, setEditorType, setForceSingle, setID, setJavaScriptObject, setMockMode, setNextElement, setSupportsMultipleInputRecords, setTypeTitle, setUndefinedComponentMessage, setUnresolvedComponentMessage, setWaitDuration, setWaitFor, setWaitLocator, updateGlobalIDInCriteria, updateGlobalIDInTextFormula, updateGlobalIDInValueProperty, updateGlobalIDInValues, updateGlobalIDReferences, updateLastElementBindingReferences, updateLastElementInCriteria, updateLastElementInValueProperty, updateLastElementInValuesMethods inherited from class com.smartgwt.client.core.BaseClass
addDynamicProperty, addDynamicProperty, addDynamicProperty, addDynamicProperty, applyFactoryProperties, asSGWTComponent, clearDynamicProperty, createJsObj, destroy, doAddHandler, doInit, error, error, errorIfNotCreated, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsElement, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAttributeAsMap, getAttributeAsString, getAttributeAsStringArray, getClassName, getConfig, getHandlerCount, getRef, getRuleScope, getScClassName, getTestInstance, hasAutoAssignedID, hasDynamicProperty, internalSetID, internalSetID, isConfigOnly, isFactoryCreated, onBind, registerID, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setConfig, setConfigOnly, setFactoryCreated, setProperty, setProperty, setProperty, setProperty, setRuleScope, setScClassName
-
Constructor Details
-
ScriptTask
public ScriptTask() -
ScriptTask
-
ScriptTask
-
ScriptTask
-
ScriptTask
-
-
Method Details
-
getOrCreateRef
-
create
-
setDataSources
Comma-separated list of DataSource IDs to pre-load into the server-side scripting context before this task executes. The listed DataSources become available as DataSource instances and same-named local variables.This is the task-level equivalent of
OperationBinding.dataSourcesandProcess.dataSources; it scopes the pre-load to a single ScriptTask rather than the entire operationBinding or process.DataSources already listed on the operationBinding or process do not need to be repeated here.
- Parameters:
dataSources- New dataSources value. Default value is null- Returns:
ScriptTaskinstance, for chaining setter calls- Throws:
IllegalStateException- this property cannot be changed after the underlying component has been created- See Also:
-
getDataSources
Comma-separated list of DataSource IDs to pre-load into the server-side scripting context before this task executes. The listed DataSources become available as DataSource instances and same-named local variables.This is the task-level equivalent of
OperationBinding.dataSourcesandProcess.dataSources; it scopes the pre-load to a single ScriptTask rather than the entire operationBinding or process.DataSources already listed on the operationBinding or process do not need to be repeated here.
- Returns:
- Current dataSources value. Default value is null
- See Also:
-
setIsAsync
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 asynchronous task is expected to start processing in execute(), and will not be considered complete
setOutput()is called.- Parameters:
isAsync- New isAsync value. Default value is false- Returns:
ScriptTaskinstance, for chaining setter calls- Throws:
IllegalStateException- this property cannot be changed after the underlying component has been created
-
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 asynchronous task is expected to start processing in execute(), and will not be considered complete
setOutput()is called.- Returns:
- Current isAsync value. Default value is false
-
setLanguage
Scripting language for theexecute()body. When running inside anOperationBinding.process, this controls which script engine evaluates the code:nullor"graal.js"(default) — execute in the current GraalJS server context, with full access to Smart GWT APIs andProcess.state- Any other value (e.g.
"groovy") — delegate to the JSR-223ScriptEngineregistered under that name. The engine receives these bindings:dsRequest,criteria,values,oldValues,session,config, andprocessState(theProcess.statemap)
This attribute has no effect in client-side workflows.
- Parameters:
language- New language value. Default value is null- Returns:
ScriptTaskinstance, for chaining setter calls- Throws:
IllegalStateException- this property cannot be changed after the underlying component has been created- See Also:
-
getLanguage
Scripting language for theexecute()body. When running inside anOperationBinding.process, this controls which script engine evaluates the code:nullor"graal.js"(default) — execute in the current GraalJS server context, with full access to Smart GWT APIs andProcess.state- Any other value (e.g.
"groovy") — delegate to the JSR-223ScriptEngineregistered under that name. The engine receives these bindings:dsRequest,criteria,values,oldValues,session,config, andprocessState(theProcess.statemap)
This attribute has no effect in client-side workflows.
- Returns:
- Current language value. Default value is null
- See Also:
-
setPassThruOutput
Does this processElement pass through output from the last executed task (i.e. transient state)?See
taskInputExpressionsfor details on the transient state outputs.Note that this property does not affect the task at all but is an indicator to the user and to the workflow editor of the behavior of the task as coded (See
Process.passThruTaskOutput()).- Overrides:
setPassThruOutputin classProcessElement- Parameters:
passThruOutput- New passThruOutput value. Default value is false- Returns:
ScriptTaskinstance, for chaining setter calls- Throws:
IllegalStateException- this property cannot be changed after the underlying component has been created
-
getPassThruOutput
Does this processElement pass through output from the last executed task (i.e. transient state)?See
taskInputExpressionsfor details on the transient state outputs.Note that this property does not affect the task at all but is an indicator to the user and to the workflow editor of the behavior of the task as coded (See
Process.passThruTaskOutput()).- Overrides:
getPassThruOutputin classProcessElement- Returns:
- Current passThruOutput value. Default value is false
-
execute
Execute the task. The return value, if notundefined, will be written as the output.For an asynchronous task, the return value is ignored and the task should call
setOutput()to continue the process with the next task.- Parameters:
input- the task inputinputRecord- the task input record ifinputsis specified. SeeTaskIO- Returns:
- the task output. For multiple field output, call
setOutput()instead, and return null
-
setOutput
public void setOutput()Sets the task output available to the next task viaProcess.getLastTaskOutput()or more commonly, with aTaskInputExpressionproperty. IfoutputFieldListis specified, the output will also be written to the specified fields in the process state (SeeTaskIO).To have the output written as-is to the process state, see
bindOutput.NOTE: for an
asynchronous task, callingsetOutput()indicates the task is complete.- See Also:
-
setOutput
Sets the task output available to the next task viaProcess.getLastTaskOutput()or more commonly, with aTaskInputExpressionproperty. IfoutputFieldListis specified, the output will also be written to the specified fields in the process state (SeeTaskIO).To have the output written as-is to the process state, see
bindOutput.NOTE: for an
asynchronous task, callingsetOutput()indicates the task is complete. -
setOutputData
Set the task output as specified byoutputField.NOTE: for an asychronous task, calling
setOutputData()indicates the task is complete. For a task withmultiple outputs, callScriptTask.setOutputRecordinstead.- Parameters:
taskOutput- task output
-
onInit_ScriptTask
protected void onInit_ScriptTask() -
onInit
protected void onInit()- Overrides:
onInitin classProcessElement
-