1 Reply Latest reply on Feb 15, 2010 5:29 AM by sebastian.s

    Manage transitions in java node

      Hi guys,

      my "problem" is:

      I am using jBPM 4.3 and i have a java node:

           <java class="it.sample.Action" g="67,348,92,52" method="getOutput" name="Action" var="output">
                <arg>
                     <object expr="#{inputObj}">
                          <property name="keyword"><string value="CLIENT CODE"/></property>
                          <property name="location"><string value="0,0,2539,700"/></property>
                          <property name="fieldRegExp"><string value="([0-9][\\s]*?){6}"/></property>
                     </object>
                </arg>
                <transition g="-68,-18" name="to evaluate result" to="evaluate result"/>
                  <transition name="to error" to="error" g="-42,-18"></transition>
           </java>
      

       

      and my class is:

      public class Action{
      
      public MyClass getOutput(InputObj obj){
                try {
                     MyClass output = obj.getOutput();
                     return output;
                } catch (Exception e) {
                     e.printStackTrace();
                          // TODO: REDIRECT TO ERROR TRANSITION
                }
                
           }
      }
      

       

      and it works, but I need to take transition "to error" (the one I have defined in java node) when I catch an Exception and I don't know how to do that.

      I've tried to use a <custom> node instead implementing ExternalActivityBehaviour but i don't know how to pass my argument to execute method. I can't set the arguments as variables in previous nodes, because my chiefs pretend to perform the operation in one step.

      Any suggestion to solve this?

      Thanks in advance

        • 1. Re: Manage transitions in java node
          sebastian.s

          In case you want to chose the transition inside your java activity AFAIK you have to use the custom task instead of the java task. You can inject variables by using:

           

          <field name="variableName"><string value="a string value"/></field>
          1 of 1 people found this helpful