Community

Beginner Question: How to pass process variables to a Java Task

created by Paul Mueller in jBPM - View the full discussion

Hi!

 

I am new to jBPM, and i currently do not understand how to pass process variables into a Java Task.


To start the java task i have this code fragment:

 

<java name="MyMethod" method="testMethod" var="result">
      <arg>
              <string value="#{test}"/>     
      </arg>

</java>


The java method:

 

public String testMethod( String testIn )
{
  System.out.println(testIn);
  return testIn+"_result";
}

 

To start the process i have this:

 

Map<String,Object> variables = new HashMap<String,Object>();
variables.put("test", "a test text");
pi = executionService.startProcessInstanceByKey("MyProcess", variables );

 

As a result i got "#{test}" and not "a test text". So what i am doing wrong?

And what is the best practice to pass process variables to a java task?

 

Thanks for help!

 

          Paul

Reply to this message by going to Community

Start a new discussion in jBPM at Community