4 Replies Latest reply on Jul 17, 2006 4:38 AM by Stylianos Limnaios

    Custom fork - jbpm 3

    Stylianos Limnaios Newbie

      Hi I'm trying to make a custom fork. The number of the Transitions is dynamic and different in each process instance. In the process definition I have added one Transition leaving from the fork. A loop in its action handler, creates new tokens for 1-n times and lets the current token to do the n Transition.

       public void execute(ExecutionContext executionContext) throws Exception {
       String parts = (String)executionContext.getContextInstance().getVariable("txtParticipantList");
       String p = (String)executionContext.getContextInstance().getVariable("tmpParticipant");
       String[] users = parts.split(",");
       if (p == null || p.equals("")){
       Transition transition = executionContext.getTransition();
       for (int j=0; j<users.length-1; j++) {
       String user = users[j];
       Token newToken = new Token(executionContext.getToken(), "dist." + j);
       ExecutionContext newExecutionContext = new ExecutionContext(newToken);
       newExecutionContext.setVariable("tmpParticipant", user);
       newExecutionContext.setVariable("pCount", Integer.toString(users.length));
       executionContext.getTransitionSource().leave(newExecutionContext, transition);
       executionContext.setVariable("txtParticipant", users[users.length-1]);
       executionContext.setVariable("pCount", Integer.toString(users.length));
       executionContext.getContextInstance().setVariable("txtParticipant", p);
       executionContext.setVariable("pCount", Integer.toString(users.length));

      The swimlane for the task after the fork is

       <swimlane name="reviewer">
       <assignment expression="variable(txtParticipant)"/>

      My problem is that the 'txtParticipant' although is set, the delegation doesn't see. It thinks that is null and throws delegation exceptions.

      I was based on that:

      Any ideas?