cancel
Showing results for 
Search instead for 
Did you mean: 

How to access a custom bean variable in an XML condition expression ?

cnirparis
Champ in-the-making
Champ in-the-making
Hello everyone.

I launch programmatically the tasks of my BPMN workflow (so I don't use JavaDelegate in my classes). I have made a java bean for passing variables from task to task (and that I get from a processInstanceQuery).
I set a boolean variable in my bean in a Java program.
The problem I have is that I'm not able to test this in a XML level, in a condition sequence flow like this one :

      <sequenceFlow id="flowRejet" name="Rejet" sourceRef="exclusivegateway1" targetRef="CorrectionErrorTask">
        <conditionExpression xsi:type="tFormalExpression"><![CDATA[${mybean.myvalue == false}]]></conditionExpression>
      </sequenceFlow>


I get

Exception in thread "main" org.activiti.engine.ActivitiException: Unknown property used in expression: ${mybean.myvalue == false}


I've added this to my activiti.cfg.xml  :

  <bean id="mybean" class="mypackage.mybean"></bean>


and this to my processEngineConfiguration bean

    <property name="beans">
      <map>
         <entry key="mybean" value-ref="mybean" />
      </map>
    </property>


without any success. I suspect Activiti engine cannot "see" my bean, or perhaps there is a bad syntax in my condition expression ?

Thank you  if you have an answer.
2 REPLIES 2

cnirparis
Champ in-the-making
Champ in-the-making
Ok, close this topic. I've changed my source code testing a boolean return value from a java method and it works :
<code>
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${!mybean.isValidated()}]]>
</code>

jbarrez
Star Contributor
Star Contributor
Ok, thanks for posting back your solution