cancel
Showing results for 
Search instead for 
Did you mean: 

add additional variable

tomi87
Champ in-the-making
Champ in-the-making
Hello,
I'm playing right now a little bit with the loanrequest.bpmn20.xml

My question is now, is it possible to add a new variable to my object ?

At first their are some variable which are created:
 <startEvent id="theStart">
      <extensionElements>
        <activiti:formProperty id="name" name="Name" required="true" type="string" />
        <activiti:formProperty id="emailAddress" name="Email address" required="true" type="string" />
        <activiti:formProperty id="income" name="Income" required="true" type="long" />
        <activiti:formProperty id="loanAmount" name="Loan amount" required="true" type="long" />
      </extensionElements>
    </startEvent>

Then the variable are "written" in the new object which is created:
<serviceTask id="createApplication" activiti:class="org.CreateApplicationTask" />

How can I write NOW a new variable in this object ?
I tried it with this:
<activiti:formProperty id="anotherName" name="Add another name" expression="#{loanApplication.addName}" required="true"/>
This is not working. Maybe I used it wrong.
What should be the right command?

And how can I override some existing POJO-variable?
If I set writable on true, I get an error: expression="${loanApplication.creditCheckOk}" writable="true"/>

Best regards!
8 REPLIES 8

frederikherema1
Star Contributor
Star Contributor
expression="#{loanApplication.addName}"
Does the loanApplcation java-object have a method "setAddName()"? Because that's what the expression's setter will resolve to, when you try to write the value…

tomi87
Champ in-the-making
Champ in-the-making
Do you mean the normal getter and setter methods ?

frederikherema1
Star Contributor
Star Contributor
Yes, I do. What exactly are you trying to do? Have the value of the form-property be set, using the loanApplication.setAddName()? Than it should just work.

Also, what exception are you getting (+ root cause)?

tomi87
Champ in-the-making
Champ in-the-making
I want to set a variable and then to call it.
Example:

<startEvent id="start">
<extensionElements>
<activiti:formProperty id="studentName" name="Student name" required="true" type="string" />
…..
<serviceTask id="createRequest" name="Create Request" activiti:class="org.process1.CreateStudentApp"></serviceTask>

<userTask id="usertask1" name="usertask 1" activiti:candidateGroups="management">
<extensionElements>
<activiti:formProperty id="showName" name="Name" expression="${loanApplication.customerName}" writable="false" />
<activiti:formProperty id="addingName" name="Add Name" expression="#{loanApplication.addName}" required="true"/>

<userTask id="usertask2" name="usertask 2" activiti:candidateGroups="management">
<extensionElements>
<activiti:formProperty id="showaddedName" name="Name" expression="${loanApplication.addName}" writable="false" />

And you mean instead of:
<activiti:formProperty id="addingName" name="Add Name" expression="#{loanApplication.addName}" required="true"/>
I should use:
<activiti:formProperty id="addingName" name="Add Name" expression="#{loanApplication.setAddName()}" required="true"/>
?

CreateApplicationTask class and LoanApplication class:
public class CreateApplicationTask implements JavaDelegate {
public void execute(DelegateExecution execution) {
  LoanApplication la = new LoanApplication();
  la.setCustomerName((String) execution.getVariable("name"));
  execution.setVariable("loanApplication", la);}}

public class LoanApplication implements Serializable {
private static final long serialVersionUID = 1L;
private String customerName;
private String addName;

public String getAddName() {return addName;}
public void setAddName(String addName) {this.addName = addName;}

frederikherema1
Star Contributor
Star Contributor
Hmm… You should just use "#{loanApplication.addName}", you should only make sure the object has a get/set method. How do you deploy the complied class-file to the activiti-engine.

tomi87
Champ in-the-making
Champ in-the-making
you should only make sure the object has a get/set method.
I think thats this or is it not what you mean?
   private String addName;
   public String getAddName() {return addName;}
   public void setAddName(String addName) {this.addName = addName;}

How do you deploy the complied class-file to the activiti-engine.

At first I use the build.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<project name="zzloanrequest.setup" default="create.zzloanrequest">
<property name="dist.dir" value="./dist" />
<target name="dist.rmdir">
  <delete dir="${dist.dir}" /> </target>
<target name="dist.mkdir" depends="dist.rmdir">
  <mkdir dir="${dist.dir}" /> </target>
<target name="zzloanrequest.jar" depends="dist.mkdir">
   <jar destfile="${dist.dir}/zzloanrequest.jar" basedir="../../../target/classes" includes="org/**" /></target>
<target name="zzloanrequest.bar" depends="dist.mkdir">
   <jar destfile="${dist.dir}/zzloanrequest.bar" basedir="."includes="*.bpmn20.xml"/></target>
<target name="create.zzloanrequest" depends="dist.mkdir, zzloanrequest.jar, zzloanrequest.bar"/>
</project>
And then I deploy the .bar file with the Activiti explorer (drag & drop).

frederikherema1
Star Contributor
Star Contributor
Can you check if the built jar-file is indeed the updated version, that is in the tomcat lib or web-inf/lib. Also, do you restart your tomcat after the jar is in place? Because tomcat doesn't reload classes when not restarted.

tomi87
Champ in-the-making
Champ in-the-making
Thank you now it's working.
The version was wrong.