jBPM simple nodes development jBPM mail nodes development
Feb 14

Decision node

jBPM decision nodes are very useful to create some alternative path along the workflow. The implementation of this node will choose the correct way.

Decision node example

To program these kind of nodes I prefer to develop a DecisionHandler rather than using an expression.

public class Validacion implements DecisionHandler{
....
}

Implement a decide method is mandatory:

public String decide(ExecutionContext executionContext) throws Exception;

Among this function code lines you can query database, consult session or recover variables from execution context:

executionContext.getVariable("previouslySetVariable");

This function must return a String containing the name of the transition to choose.

As the other nodes, you must configure the handler class with the node using Eclipse interface.

Decision node configuration

Related Posts

9 Responses to “jBPM decision nodes development”

  1. Kodee Says:

    hey thts pretty helpful. It would be of great help if you have sample DecisionHandler class

  2. pigui Says:

    It’s pretty simple.

    public class Decision implements DecisionHandler{

    public String decide(ExecutionContext executionContext) throws Exception {
    Boolean b = (Boolean) executionContext.getVariable(”finish”);
    if (b.booleanValue()){
    return “yes”;
    }
    return “no”;
    }
    }

    Where “yes” and “no” are transition names to other nodes and “finish” is a variable set in another place of execution.

  3. kodee Says:

    Thanks pigui

  4. Fornachari Says:

    You are doing a great job in this blog.

    Could you tell me how could be possible do a decision node using an expression, I am trying here but I can’t find how the right way to write a expression, I don’t know how to do the condition.

    Thank you!

  5. Fornachari Says:

    I found how do it:

    =200) ? ‘Yes’ : ‘No’}”>

    It works.
    Thank you!

  6. Fornachari Says:

    Sorry, I don’t know why didn’t post right, let try again:

    expression=”#{(someVar>=200) ? ‘Yes’ : ‘No’}”

  7. pigui Says:

    @Fornachari
    I have been in a conference nearly all this week and I couldn’t reply to your questions. I’m sorry.
    http://blogs.dfwikilabs.org/pigui/2008/06/30/workshop-at-salamanca/

    Now I back to my office and I’ve seen that you post something about mail nodes at http://blogs.dfwikilabs.org/pigui/2008/02/15/jbpm-mail-nodes-development/#comment-441. I’m going to answer you right now.

  8. Tommy Says:

    How does the decision node differ from a regular state node.
    Isn’t it possible to have a “switch” logic in a java class implemented in a regular state node, and then choose the transition based on that logic?

  9. pigui Says:

    @Tommy

    I don’t know, if I have to choose between two or more transitions I always use a decision node. It is so easy/fast to develop.

Leave a Reply