This sample demonstrates the following:
-
How to programmatically create process actors on process start using the
ProcActionsFragment
; -
How to pass process variables to the process instance using the
ProcActionsFragment
; -
How to get and modify standard process actions created by the
ProcActionsFragment
(e.g. change "Start process" button caption); -
How to start a process programmatically without the
ProcActionsFragment
; -
How to automatically update the
processState
field each time the process moves further using theActivitiEventListener
.
The sample uses the Task execution – 1 process model:
In this example, we don’t use the StandardProcForm
to assign process actors. We do it with the help of the before start process predicate of the ProcActionsFragment
. See the setBeforeStartProcessPredicate()
method.
link:../../../source/examples/TaskEdit.java[role=include]
See the setStartProcessActionProcessVariablesSupplier()
usage in the TaskEdit.java
as an example of how to pass process variables at process start using the ProcActionsFragment
. The acceptanceRequired
process variable will be used by one of the process gateways to decide whether the task must be accepted by the initiator or the process must be completed.
The changeStartProcessBtnCaption()
demonstrates that you can get and modify process actions generated by the ProcActionsFragment
. In this method, the standard button caption "Start process" is replaced by the custom one.
The onStartProcessProgrammaticallyBtnClick()
method demonstrates how to start a new process instance without the ProcActionsFragment
.
The UpdateProcessStateListener.java
is an implementation of the org.activiti.engine.delegate.event.ActivitiEventListener
. This listener is registered as a process-level listener. It does the following: each time a new process step is reached, the processState
field of the related com.company.bpmsamples.entity.Task
entity is updated with the current process step name.
link:../../../source/examples/UpdateProcessStateListener.java[role=include]
That’s how process-level event listeners configuration looks in the process model.
To open this window click somewhere in the modeler, click the Show advanced properties link and then go with the Event listeners property.