[jboss-user] [JBoss jBPM] - How to take a decision in java code
Jean-LucT
do-not-reply at jboss.com
Thu Sep 6 11:15:11 EDT 2007
I'm new to jBPM 3.2.1 but I didn't find anything on this subject either in doc/examples and this forum : still my question seems to me very basic.
I want to be able to decide the transition I will follow in a piece of Java Code according to the data previously entered.
I'm using a Decision node for this with two transition (Oui and Non).
I've added an action/"Node Enter". This action map a java class using the field setup.
My java code :
public class DecideIfCustomer implements ActionHandler {
| private static final Logger logger = Logger.getLogger(IsCustomer.class);
|
| public DecideIfCustomer() {
| super();
| }
|
| public void execute(ExecutionContext executionContext) throws Exception {
| Node node = executionContext.getNode();
| ContextInstance contextInstance = executionContext.getContextInstance();
| if (contextInstance.getVariable("Nom du contact").equals("Non")) {
| node.leave(executionContext, "Non");
| }
| }
|
| }
|
Notice that my class is an instance of ActionHandler because I've not been able to use a DecisionHandler. When using a DecisionHandler I got a ClassCastException.
With this, I'm able to go through the transition Non when my variable is correctly set BUT : I noticed that in fact it takes the Non transition twice and then go to the Oui transition.
I guess I missed something, anyhelp ?
My process-definition for the decision node :
<decision name="Client actif ?">
| <event type="node-enter">
| <action name="isCustomerAcitf" class="fr.jl2tho.tutorialjbpm.action.DecideIfCustomer"></action>
| </event>
| <transition name="Oui" to="Enregistrer la Question"></transition>
| <transition name="Non" to="Prevenir le commercial"></transition>
| </decision>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4081708#4081708
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4081708
More information about the jboss-user
mailing list