3 Replies Latest reply on Dec 2, 2005 5:18 PM by koen.aers

    Execution - TaskInstance

    pjmvn

      Hi all.
      I have an class for action event in GPD.

      <event type="task-create">
       <action class="jbpm.Create"/>
      </event>

      Class:
      public class Create implements ActionHandler {
      
       private static final long serialVersionUID = 1L;
      
       public void execute(ExecutionContext executionContext) throws Exception {
       System.out.println("=======");
       ArrayList list=new ArrayList();
       list.add("first");
       list.add("second");
       executionContext.setVariable("list", list);
       System.out.println("===================");
       }
      }

      And then in TaskBean.java of jbpm.war
      in initialize() function i add:
      System.out.println("====== read my data =======");
      
       myData = (List)taskInstance.getVariable("list");
       if (myData!=null){
       for (int i=0;i<myData.size();i++){
       System.out.println((String)myData.get(i));
       }
       }
       System.out.println("============================");

      This code is correct but myData is null.
      Why? I am wrong?
      Help me please.
      Thanks

        • 1. Re: Execution - TaskInstance
          koen.aers

          You have associated your variable with the execution context in the first snippet and are trying to read it from the freshly created task instance in the second snippet. Only the task is already created before you add the variable to the execution context.

          Regards,
          Koen

          • 2. Re: Execution - TaskInstance
            kukeltje

            Koen,

            What he does would have worked in 3.0 and 3.01 since the variables would not have been copied to be used in the task. In 3.02 all variables with their respective values are copied when a task is created.

            I to did not know this when I upgraded from 3.01 to 3.02. and it cost me several hours to find out

            • 3. Re: Execution - TaskInstance
              koen.aers

              Mmm yeah agreed, this is not very well documented. We apologize...

              Regards,
              Koen