cancel
Showing results for 
Search instead for 
Did you mean: 

Java Bean Variable not visible to bpmn expressions

arihant_banthia
Champ in-the-making
Champ in-the-making
Hi, I am new to Activiti and i am trying to pass a Java bean object variable using setVariable() method. When I try to call a getter method in bpmn expression it doesn't display the value in Activiti UI but i am able to retrieve the same variable using the getVariable() method. Can you please tell me what I am doing wrong?

Here is the BPMN task where I specify the variable:

<startEvent id="startevent1" name="Start" activiti:initiator="employeeName">
      <extensionElements>
        <activiti:formProperty id="roleName" name="Role" type="string" required="true"></activiti:formProperty>
        <activiti:formProperty id="manager" name="Manager" type="string" required="true"></activiti:formProperty>
        <activiti:formProperty id="roleInfo" name="Role Info" variable="roleInfo"></activiti:formProperty>
      </extensionElements>
    </startEvent>


Variable call in Workflow:

<activiti:formProperty id="roleType" name="Role Type" type="string" expression="${roleInfo.getIdentifier()}" variable="${roleInfo}" writable="false"></activiti:formProperty>


I pass this variable using the following code:

                EntityInfo entityInfo = new EntityInfo();
      entityInfo.setIdentifier("TDM_Role");
      entityInfo.setOid("Role-oid");
      entityInfo.setRequestable(true);
      runtimeService.setVariable(processInstance.getId(), "roleInfo", entityInfo);


<b>Note:</b> I am using StandaloneProcessEngineConfiguration.
6 REPLIES 6

jbarrez
Star Contributor
Star Contributor
Why are you using the form properties here? Are you using explorer somehow with a custom form property type?

If you set the variable like that, you will be able to retrieve it using runtimeService.getVariable(), but if you want to use it with form properties, you need custom form properties…

arihant_banthia
Champ in-the-making
Champ in-the-making
I was using the activiti explorer only. So I found the solution by declaring the custom bean "roleInfo" in "\webapps\activiti-explorer\WEB-INF\activiti-standalone-context.xml".
<blockcode>
<bean id="roleInfo" class="com.confluxsys.DemoCertification.RoleDTO" />
</blockcode>
Is it the correct way to do it ?

yvoswillens
Champ in-the-making
Champ in-the-making
The bean has be known by the Spring Context. So for the Activiti Explorer this could be done the way you did it.

arihant_banthia
Champ in-the-making
Champ in-the-making
Is there a better way to do it as over time my implementation might change and it may be difficult to keep a track of all the variables and their implementing classes?

Thanks in advance

jbarrez
Star Contributor
Star Contributor
Not if you want to use pojo's as process variables. An alternative is using primitive values here instead of objects.

arihant_banthia
Champ in-the-making
Champ in-the-making
Hi,
Thanks for the info. It helped a lot.