activiti:在调用Activity中将变量从被调用进程传递给调用进程

时间:2014-02-18 23:11:22

标签: java activiti

这是我的通话流程:

<process id="myProcess" name="My process" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <callActivity id="callactivity1" name="Call activity" calledElement="mySubProcess">
      <extensionElements>
        <activiti:out source="outp" target="outpp"></activiti:out>
      </extensionElements>
    </callActivity>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="callactivity1"></sequenceFlow>
    <boundaryEvent id="boundaryerror1" name="Error" attachedToRef="callactivity1">
      <errorEventDefinition></errorEventDefinition>
    </boundaryEvent>
    <scriptTask id="scripttask1" name="Script Task" scriptFormat="groovy" activiti:autoStoreVariables="true">
      <script>System.out.println(outpp + " ??")</script>
    </scriptTask>
    <sequenceFlow id="flow2" sourceRef="boundaryerror1" targetRef="scripttask1"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow3" sourceRef="callactivity1" targetRef="endevent1"></sequenceFlow>
    <sequenceFlow id="flow4" sourceRef="scripttask1" targetRef="endevent1"></sequenceFlow>
  </process>
</definitions>

而且,这是我称之为的过程:

<process id="mySubProcess" name="My process" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <scriptTask id="scripttask1" name="Script Task" scriptFormat="groovy" activiti:autoStoreVariables="true">
      <script>String outpa = "asd"
outp = outpa
System.out.println(outp)</script>
    </scriptTask>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="scripttask1"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow2" sourceRef="scripttask1" targetRef="endevent1"></sequenceFlow>
    <endEvent id="errorendevent1" name="ErrorEnd">
      <errorEventDefinition errorRef="errorEnd"></errorEventDefinition>
    </endEvent>
    <sequenceFlow id="flow3" sourceRef="scripttask1" targetRef="errorendevent1">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${ outp != ""}]]></conditionExpression>
    </sequenceFlow>
  </process>
</definitions>

当我部署进程并启动myProcess时,出现错误:

problem evaluating script: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: outpp for class: Script2

我似乎无法找出问题所在。虽然输入参数传递给子进程没有任何问题,但在尝试使用输出参数

时出现此错误

由于

1 个答案:

答案 0 :(得分:0)

我想我找到了答案。如果调用活动中的错误边界事件捕获到错误,则不会在调用进程中设置输出参数。解决方法是不使用错误边界事件和错误结束事件;但是只需将变量传递给主进程并根据变量的值处理流(可以使用独占网关)。