0 Replies Latest reply on Oct 31, 2006 9:47 PM by jrojas_pb

    Associating variables to task instances

    jrojas_pb Newbie

      Hi,

      I am having difficulty associating variables with task instances. I am using hypersonic to test my code and when I check the JBPM_VARIABLEINSTANCE table, the TASKINSTANCE_ column is null.

      My process definition loops over the same task node multiple times. Each time the token reaches the task node, a new task instance is created, but I cannot find the variable instance "var1" for each task instance.

      For now, I am concatinating the task instance id to the variable name, but from reading the documentation, I thought that taskInstance.setVariable( "var name", object ) would assign "var name" to that task instance, and assigning "var name" to another task instance would not change the value of the 1st assignment.

      Thanks in advance for your help.

      Regards,

      John

      The task action handler is shown below:

       public static class TaskNodeAction implements ActionHandler
       {
       private static final long serialVersionUID = 1L;
       String value1;
       public void execute(ExecutionContext context) throws Exception
       {
       TaskInstance taskInstance = context.getTaskInstance();
       if( taskInstance == null )
       logger.error( "Got null taskInstance in node=" + context.getNode().getFullyQualifiedName() );
       else
       {
       // load custom variables and start it.
       taskInstance.setVariable( "var1", value1 );
       taskInstance.start();
       }
       }
       }
      


      The task node out of the process definition:
       <task-node name="Looping Task">
       <task name="Looping Task">
       <event type='task-create'>
       <action class='TaskNodeAction'>
       <value1>1234</value1>
       </action>
       </event>
       </task>
       <transition name="" to="next transition"></transition>
       </task-node>