ActionForm actions are user components that allow you to perform any action on the task form in response to user actions, data changes or other form events. Examples of actions can, for example. - perform mathematical calculations, e.g. convert net amounts, sum values, calculate rates
- add comments
- display messages
- communicate with the server in order to download data
- freely change the values of task variables (via FormAPI)
The created actions are available in the process editor and can be easily used in the business process enabling the execution of business logic. Their behavior can be further configured using parameters. Info |
---|
The ECMAScript 6 standard is supported in the browser-side actions created. |
Defining actionsActions are created based on their definition created by the user. Such a definition must contain the following elements: - An annotation
Javadoc |
---|
displayValue | @Actions |
---|
property | javadoc.plusworkflow |
---|
className | com.suncode.pwfl.workflow.form.action.annotation.Actions |
---|
| (if the action is not defined in the plug-in, it must come from the com.suncode package) - An annotation
Javadoc |
---|
displayValue | @ActionsScript |
---|
property | javadoc.plusworkflow |
---|
className | com.suncode.pwfl.workflow.form.action.annotation.ActionsScript |
---|
| An annotation transferring the path to the script (from classpath) containing the JavaScript implementation, or the path along with the fragments in which the script will be placed (for example, if the action is placed in the process history). In the first case, we specify only the path, while in the second case the path lands in the value parameter, and the fragments in the fragments object. The available values for fragments can be found in the class Javadoc |
---|
displayValue | ActionUIFragment |
---|
property | javadoc.plusworkflow |
---|
className | com.suncode.pwfl.workflow.form.action.ActionUIFragment |
---|
| . - Public method annotated
Javadoc |
---|
displayValue | @Define |
---|
property | javadoc.plusworkflow |
---|
className | com.suncode.pwfl.component.annotation.Define |
---|
| with a single parameter Javadoc |
---|
property | javadoc.plusworkflow |
---|
className | com.suncode.pwfl.workflow.form.action.ActionDefinitionBuilder |
---|
| (many different actions can be defined in a single @Actions class)
An action can also provide a script that builds the appearance of parameters when it is defined in the PWE. To do this, add another annotation for the class Javadoc |
---|
displayValue | @ComponentsFormScript |
---|
property | javadoc.plusworkflow |
---|
className | com.suncode.pwfl.workflow.form.component.annotation.ComponentsFormScript |
---|
| with the path to the script transferred (from classpath).An example definition is shown below: Code Block |
---|
language | java |
---|
linenumbers | true |
---|
| @Actions
@ActionsScript( "actions/example.js" )
@ComponentsFormScript( "actions/example-form.js" )
public class ExampleActions
{
@Define
public void action( ActionDefinitionBuilder action )
{
action
.id( "hide-variables" )
.name( "action.hide-variables.name" )
.description( "action.hide-variables.desc" )
.icon( SilkIconPack.EYE )
.category( Categories.TEST )
.destination( ActionDestination.button() )
.parameter()
.id( "variables" )
.name( "action.hide-variables.variables.name" )
.description( "action.hide-variables.variables.desc" )
.type( Types.VARIABLE_ARRAY )
.create();
}
} |
Sample definition for an action placed both on the form and in the history: Code Block |
---|
@Actions
@ActionsScript( value = "actions/example.js", fragments = { ActionUIFragment.FORM, ActionUIFragment.HISTORY } )
public class ExampleActions |
Destination elements (destination) Destination elements are indicated at the action definition stage in the destination() method. They specify to which form elements the action can be added: Element | Description | Examples of actions | Selection in PWE |
---|
ActionDestination.form() | Form The action added to the form is initiated with the formInit method. | Actions in which the main element cannot be indicated, e.g. - hiding multiple variables at the same time
| Image Added | ActionDestination.variable() | Variable The action added to the form variable is initialized with the variableInit method in the parameter receiving an object of this variable ( Jsdoc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.variable.Variable |
---|
| ). | Actions in which it is possible to clearly indicate the variable to which the action applies (to the greatest extent), e.g. - hiding a variable
- live validation of a variable (e.g. showing a message without acceptance)
| Image Added | ActionDestination.variableSet() | Dynamic table The action added to the form variable is initialized with the variableSetInit method in the parameter receiving a dynamic table object ( Jsdoc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.field.VariableSet |
---|
| ). | Actions that apply to a dynamic table and need its identifier, for example. - add a title to the table based on calculations
- import data into the table (action adds a button to the table)
| Image Added | ActionDestination.button() | Button The action added to the form button is initialized with the buttonInit method in the parameter receiving the button object ( Jsdoc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.button.Button |
---|
| ). | Actions whose source is a button, e.g. - adding a comment before acceptance
- displaying messages after clicking the button
| Image Added | ActionDestination.dtButton() | Table button The action added to the form's table button is initialized with the dtButtonInit method in the parameter receiving the button object ( Jsdoc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.button.DtButton |
---|
| ). | | The action is added at the add/edit level of the form table button: Image Added
| ActionDestination.label() | Label The action added to the label on the form is initialized with the labelInit method in the parameter receiving the label object ( Jsdoc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.field.Label |
---|
| ). | | Image Added
|
Action initialization Warning |
---|
Functionality not yet available. |
The creator of the process in action can specify its initialization type. Available types: The selected parameter is readable by the action in the getInitializationType function. Setting this parameter DOES NOT affect the operation of the action unless the action creator has implemented it. Assigning a target element to a parameter (bindTo)The selected target element of the action can be transferred to the action parameter by specifying the target parameter ID in the bindTo parameter. E.g.
Code Block |
---|
| ActionDestination.variable( "text" ); // 'text' to identyfikator parametru akcji |
With the action configured in this way, if we add it to any variable, the variable will automatically be set as the value of the parameter. Depending on the target element in the parameter will be entered: Target element | Assigned value |
---|
Variable | Variable | Dynamic table | Dynamic table identifier | Button | Button ID (action name) |
Implementation of actionsThe form action defined on the server must be registered and implemented on the browser side. Registration is enabled by the class Jsdoc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.action.Actions |
---|
| using the method Jsdoc |
---|
displayValue | create |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.action.Actions.html#method_create |
---|
| . The first parameter of the method is the action id (the id must correspond to the action that has been defined on the server), the second parameter is the action implementation object: Code Block |
---|
language | js |
---|
linenumbers | true |
---|
| PW.FormActions.create('hide-variables', {
init: function(){
this.variables = this.get("variables");
this.variablesNames = [];
},
enable: function(){
this.hideVariables();
},
disable: function(){
this.showVariables();
},
hideVariables: function() {
this.setVariablesVisibility(false);
},
showVariables: function() {
this.setVariablesVisibility(true);
},
setVariablesVisibility: function(visible) {
PW.each(this.variables, function(variable){
if(visible){
variable.show();
}
else{
variable.hide();
}
}, this);
}
}); |
Default actionsIn order to simplify the creation of actions that react to default events of target elements, it is possible to define so-called default actions. The creator of the action can declare functions that will execute automatically if an event associated with the target element of the action occurs, e.g. if the action is added to a button, clicking on this button will trigger the defined default action. Info |
---|
Default actions are called only if the action execution condition is fulfilled. The parameters of the default action call are the same as the parameters of the events that are the source of the default action call. |
Default events depending on the action target element: Target element | Function name | Default event | Description |
---|
ActionDestination.button() | button | click ( Jsdoc |
---|
displayValue | doc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.button.Button |
---|
| ) | The function is called when you click on the button to which the action is added. Tip |
---|
You can abort acceptance of the form by returning false: Code Block |
---|
| defaultActions: {
button: function(button){
// do some job
return false;
}
} |
|
| ActionDestination.variable() | variable | change ( Jsdoc |
---|
displayValue | doc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.variable.Variable |
---|
| ) | The function is called when the value of the variable to which the action is added changes. | ActionDestination.variableSet() | variableSet | change ( Jsdoc |
---|
displayValue | doc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.field.VariableSet |
---|
| ) | The function is called if the value of any variable belonging to the dynamic table to which the action is added changes. | ActionDestination.form() | form | enable ( Jsdoc |
---|
displayValue | doc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.action.Action |
---|
| ) | The function is called if the condition for the action is fulfilled. | ActionDestination.dtButton() | dtButton | click ( Jsdoc |
---|
displayValue | doc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.button.DtButton |
---|
| ) | The function is called when you click on the button in the table to which the action is added. |
Below is an example implementation of an action showing a configured message. Depending on the target element, the message will show when you press a button, change the value of a variable or change the data in a table. Code Block |
---|
PW.FormActions.create('message', {
// domyślne akcje
defaultActions: {
button: function(button){
this.showMsg();
},
variable: function(variable, newValue, oldValue){
this.showMsg();
},
variableSet: function(variableSet, added, updated, removed){
this.showMsg();
},
dtButton: function(button){
this.showMsg();
},
},
showMsg: function(){
ServiceFactory.getMessageService().showSuccess(this.get('msg'));
}
}); |
Multiple sources (targets) of action Warning |
---|
Functionality not yet available. |
It is possible to specify more than one source (target) for an action, for example, to call exactly the same action if the value of one of the many specified variables has been changed. To add support for multiple targets for an action, call multitarget() in the builder: Code Block |
---|
| @Define
public void action( ActionDefinitionBuilder action )
{
action
.id( "hide-variables" )
.name( "action.hide-variables.name" )
.description( "action.hide-variables.desc" )
.icon( SilkIconPack.EYE )
.category( Categories.TEST )
.multitarget()
.destination( ActionDestination.button() )
.parameter()
.id( "variables" )
.name( "action.hide-variables.variables.name" )
.description( "action.hide-variables.variables.desc" )
.type( Types.VARIABLE_ARRAY )
.create();
} |
If the action has been added (dragged) to: - buttons
- header variables
- tables
it is possible to add more objects of the same type as sources for calling the action. If the source is a table, the successively added objects must be table variables. The action remains one and the same JavaScript object, but more than one object can trigger defaultActions events: - for buttons - each of the added buttons triggers the button event when clicked, passing itself to the event function
- for header variables - each of the added variables, after changing the value, triggers the variable event passing itself to the event function
- for table - if no additional table variables are specified, any change in the dynamic table triggers the variableSet. If additional variables are specified - a change in the dynamic table triggers the variableSet event only if the change occurred in any of the defined tabular variables (when adding or deleting a row, the variableSet event is always triggered).
Also, initialization of actions for specified variables changes its behavior slightly: - buttonInit - transfers an array of buttons (even when only one button is specified)
- variableInit - transfers an array of header variables (even when only one variable has been specified)
The lightning symbol is displayed with each added target, but editing such an action is global. Registration of actions in the pluginIf the action is defined in the plugin then you should additionally indicate that the plugin provides the action. To do this, add an entry in the suncode-plugin.xml file: Code Block |
---|
| <!-- Sharing actions -->
<workflow-components key="components" /> |
|