Feb 14
jBPM decision nodes are very useful to create some alternative path along the workflow. The implementation of this node will choose the correct way.
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.





June 25th, 2008 at 10:15 am
hey thts pretty helpful. It would be of great help if you have sample DecisionHandler class
June 25th, 2008 at 12:56 pm
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.
June 25th, 2008 at 5:24 pm
Thanks pigui
July 1st, 2008 at 2:10 pm
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!
July 1st, 2008 at 2:22 pm
I found how do it:
=200) ? ‘Yes’ : ‘No’}”>
It works.
Thank you!
July 1st, 2008 at 2:46 pm
Sorry, I don’t know why didn’t post right, let try again:
expression=”#{(someVar>=200) ? ‘Yes’ : ‘No’}”
July 4th, 2008 at 8:08 am
@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.
September 5th, 2008 at 9:08 pm
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?
September 9th, 2008 at 8:57 am
@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.