我正在使用activiti-5.21.0
。我有
我创建了myProcess.bpmn
,它有用户任务。用户任务有一个表单。当受理人用户提交此表格时,即“kermit”,那么如何读取以java类形式提交的数据?
myProcess.bpmn
型号:
<process id="myProcess" name="My process" isExecutable="true">
<startEvent id="startevent1" name="Start"></startEvent>
<userTask id="usertask1" name="User Task" activiti:assignee="kermit">
<extensionElements>
<activiti:formProperty id="name" name="Name" type="string" required="true"></activiti:formProperty>
<activiti:formProperty id="comment" name="comment" type="string"></activiti:formProperty>
<activiti:executionListener event="start" class="com.demo.ActivitiForm"></activiti:executionListener>
</extensionElements>
</userTask>
<endEvent id="endevent1" name="End"></endEvent>
<sequenceFlow id="flow1" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
<sequenceFlow id="flow2" sourceRef="usertask1" targetRef="endevent1"></sequenceFlow>
</process>
答案 0 :(得分:1)
如果您想从任何地方访问变量(无论流程如何)。使用流程实例ID,您可以尝试这个 -
Map<String, Object> variables = runtimeService.getVariables(processInstanceId);
String name = (String)variable.get("name");
String comment = (String)variable.get("comment");
答案 1 :(得分:1)
更改执行event="end"
然后尝试此操作 -
package com.demo;
//all import statement
public class ActivitiForm implements ExecutionListener {
public void notify(ExecutionListenerExecution execution) throws Exception {
String name = (String) execution.getVariable("name");
String comment = (String) execution.getVariable("comment");
System.out.println(name + " made the following comment: " + comment); //see this sys.out in your admin log.
}
}