1 Reply Latest reply on Apr 21, 2010 9:42 AM by neshap

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

    paultk

      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