2 Replies Latest reply on Dec 7, 2005 5:31 PM by koen.aers

    Can't get value of field property in my ActionHandler

    michaelholtzman

      Greetings. I am trying to write an action handler that has a String field which is populated from the process definition.

      <state name="Run Script 1">
       <transition name="GotoScript2" to="Run Script 2"></transition>
       <event type="node-enter">
       <action name="RunAvsScript1" class="com.olf.workflowmgr.action.LaunchActionHandler" config-type="field">
       <scriptName>MikeTest</scriptName>
       </action>
       </event>
       <event type="node-leave">
       <action name="SaveScript1Data" class="com.olf.workflowmgr.action.LeaveScript1ActionHandler"></action>
       </event>
       </state>


      and the corresponding class:

      public class LaunchActionHandler implements ActionHandler {
      
       private String scriptName;
      
       /**
       * Creates the variable "argt".
       *
       * @param executionContext
       * the context
       */
       public void execute(ExecutionContext executionContext) {
       ContextInstance ci = executionContext.getContextInstance();
       ProcessInstance pi = executionContext.getProcessInstance();
       String argt = (String)ci.getVariable("argt");
       String script = scriptName;
      
      <snip/>
      }
      


      The value of "scriptName" is null. Why isn't it being set to "MikeTest" as specified in the process definition xml?

      Thanx.

        • 1. Re: Can't get value of field property in my ActionHandler
          michaelholtzman

          Problem solved (replaced by new problem).

          The process instance was being created with the wrong process definition, because my process definitions are not being properly versioned when they are imported like this:

           public void initProcessDefinitions() {
           JbpmSession jbpmSession;
           // For now, only load up our sample process.
           String processName = "example_process.par/processdefinition.xml";
          
           console("Loading process definitions");
           // begin a transaction on the persistence session
           jbpmSession = jbpmSessionFactory.openJbpmSession();
          
           console("initProcessDefinitions: Reading xml file");
           ProcessDefinition definition = ProcessDefinition.parseXmlResource(processName);
           console("initProcessDefinitions: Loaded process definition '" + definition.getName()+ "' from xml");
          
           jbpmSession.beginTransaction();
          
           // Save the process definition in the database
           console("initProcessDefinitions: Saving to database");
           jbpmSession.getGraphSession().saveProcessDefinition(definition);
          
           // Commit the transaction
           console("initProcessDefinitions: Committing");
           jbpmSession.commitTransaction();
          
           // List out the stored process definitions
           java.util.List defs = jbpmSession.getGraphSession().findAllProcessDefinitions();
           console("Found " + defs.size() + " process definitions in database:");
           for (Iterator it = defs.iterator(); it.hasNext();) {
           ProcessDefinition def = (ProcessDefinition)it.next();
           console("Process definition: " + def.getName() + " / " + def.getVersion());
           }
          
           jbpmSession.close();
           console("initProcessDefinitions: Done");
          
          


          causing this to return the wrong process definition
          launchJbpmSession.getGraphSession().findLatestProcessDefinition(processName);
          
          
          See http://www.jboss.com/index.html?module=bb&op=viewtopic&t=73631



          • 2. Re: Can't get value of field property in my ActionHandler
            koen.aers

            Great, thanks for reporting back!

            Regards,
            Koen