1 Reply Latest reply on Jul 4, 2007 6:06 AM by Stefano Zaccaria

    node enter and assign localvariabile to the task instance

    Stefano Zaccaria Newbie

      Hello!
      Today I try all the day with this problem:
      I want to set a local variable to the task instance when the enter node:

      ES: I have this kind of process

      
      <process-definition
       name="todo">
      
       <start-state name="start">
       <transition to="task1"/>
       </start-state>
      
       <task-node name="task1">
       <task name="todo" description="#{todoList.description}">
       <assignment pooled-actors="commerciale"/>
       </task>
       <transition to="done" name="end"/>
       <transition name="toTask2" to="task2"></transition>
       </task-node>
      
       <end-state name="done"/>
       <task-node name="task2">
       <event type="node-enter">
       <action name="action1" class="AssegnaSuperVisore">
       <superVisore>valore</superVisore>
       </action>
       </event>
       <transition name="toTask1" to="task1"></transition>
       </task-node>
      
      
      </process-definition>
      
      


      When the wf pass from the task1 to the task2 and enter i want to set the variabile var1 with the ActionHandler class

      package xxx.xxxxxx.wf.bpm;
      
      import org.jbpm.graph.def.ActionHandler;
      import org.jbpm.graph.exe.ExecutionContext;
      import org.jbpm.taskmgmt.exe.TaskInstance;
      
      public class AssegnaSuperVisore implements ActionHandler {
      
       private String superVisore;
      
       private static final long serialVersionUID = 1L;
      
       public void execute(ExecutionContext arg0) throws Exception {
      
       TaskInstance taskInstance = arg0.getTaskInstance();
      
       if( taskInstance != null )
       taskInstance.setVariableLocally("supervisore", superVisore);
       else
       arg0.getContextInstance().setVariable("supervisore", superVisore);
      
       }
      
       public String getSuperVisore() {
       return superVisore;
       }
      
       public void setSuperVisore(String superVisore) {
       this.superVisore = superVisore;
       }
      
      }
      
      
      


      But seem that the taskInstance is every null.

      Help me!!!
      Thanks

        • 1. Re: node enter and assign localvariabile to the task instanc
          Stefano Zaccaria Newbie

          I resolve with this code

          import org.jbpm.context.exe.ContextInstance;
          import org.jbpm.graph.exe.Token;
          import org.jbpm.taskmgmt.def.TaskControllerHandler;
          import org.jbpm.taskmgmt.exe.TaskInstance;
          
          public class AssegnaSuperVisoreAlTaskInstance implements TaskControllerHandler {
          
           private static final long serialVersionUID = 1L;
          
           public void initializeTaskVariables(TaskInstance taskInstance, ContextInstance contextInstance, Token token) {
          
           taskInstance.setVariableLocally("supervisore", org.jboss.seam.core.TaskInstance.instance().getActorId());
          
           }
          
           public void submitTaskVariables(TaskInstance arg0, ContextInstance arg1, Token arg2) {
          
           }
          
          }