2 Replies Latest reply on Jun 11, 2006 5:20 PM by jpf

    Question about jBPM expression

    johnlz

      Hi,

      I am trying now to build a loop execution in my jBPM script. I know that the expression must be used here. But in order to control the amount of the loop, I think a loop-variable is also needed. I don't know how to make the variable reduce. For example, in C/++ we have i=i-1, but in jBPM how can I do this?

      My code is written as the following, it works always abnormal. Could somebody please give me some advices? Thanks!

      John

      <?xml version="1.0" encoding="UTF-8"?>
      
      <process-definition
       xmlns="http://jbpm.org/3/jpdl" name="hello">
       <start-state name="start">
       <task name="task">
       <controller>
       <variable name="MyID" access="read,write" mapped-name="decisionID"></variable>
       </controller>
       </task>
       <transition name="ini" to="decision1">
       <script>
       <expression>executionContext.setVariable("decisionID",new Integer(10))</expression>
       </script>
       </transition>
       </start-state>
       <decision name="decision1">
       <transition name="tr2" to="task1">
       <condition expression="#{contextInstance.variables['decisionID'] gt 0}" />
       </transition>
       <transition name="tr1" to="end1"></transition>
      
       </decision>
       <task-node name="task1">
       <transition name="" to="decision1">
       <script>
       <expression>executionContext.setVariable("decisionID",Integer.valueOf(Integer.parseInt(executionContext.getVariable("decisionID").toString())-1))</expression>
       </script>
       <action name="HelloWS" class="com.jbay.action.MyActionHandler"></action>
       </transition>
       </task-node>
       <end-state name="end1"></end-state>
      </process-definition>


        • 1. Re: Question about jBPM expression
          johnlz

          hi! Nobody can answer my question?

          • 2. Re: Question about jBPM expression
            jpf

            Hi,

            might it be possible that the decission node is the issue?
            I faced a similar problem (with the current jbpm 3.2 snapshot from CVS) with a node looking like this:

             <decision name="Mitreisende vorhanden?">
             <transition name="ja" to="Weitere Mitreisende angeben"></transition>
             <condition expression="#{contextInstance.variables['isAccompanied'] == true}" />
             </transition>
             <transition name="nein" to="Ende"></transition>
             </decision>
            

            Transition 2 ("nein") was never taken. I changed it to:
             <decision name="Mitreisende vorhanden?">
             <transition name="nein" to="Ende"></transition>
             <transition name="ja" to="Weitere Mitreisende angeben">
             <condition expression="#{contextInstance.variables['isAccompanied'] == true}" />
             </transition>
             </decision>
            

            Now everything is working as expected. In my opinion both solutions should have the same result because the transition without condition should always be true..


            Rgds,
            Patrick