2 Replies Latest reply on Sep 7, 2006 3:37 PM by Amit Sachde

    Calling a method from within code that has @CreateProcess do

    Amit Sachde Newbie

      I have a business process that is called from a method that is invoked from a pageflow. If I add @CreateProcess to the method which is invoked from the pageflow the process starts and variables are available on the page.

      HOWEVER if I want to use the variables in the SLSB or POJO I cant seem to get access to them. If I extract the creation of the new process then the process gets created but I have to signal it and I dont have access to any of the processInstance or the token! What's the SEAM way of doing so.

      WHAT WORKS:
      1) PageFlow has
      < action expression="#{login.logmein}" / >

      2) My POJO method is declared as
      @CreateProcess(definition="asyncProcess")
      public String logmein()

      3) My variable is declared as
      @Out(scope=ScopeType.BUSINESS_PROCESS)
      public CustomerBean getCust() {
      return cust;
      }

      4) My JSF has
      < h:outputText value="#{login.cust.streetaddress}"/ >

      5) Alternatively I could remove the @CreateProcess and write the following code where I do have programatic access to the altered cust variable
      org.jbpm.graph.exe.ProcessInstance pi = JbpmConfiguration.getInstance().createJbpmContext().getGraphSession().findLatestProcessDefinition("asyncProcess").createProcessInstance();
      Token token = pi.getRootToken();
      pi.getContextInstance().setVariable("cust", cust);
      token.signal();

      CustomerBean cc = (CustomerBean) pi.getContextInstance().getVariable("cust");

      But that does not seem like the SEAM way of doing things.

      WHAT DOES NOT WORK:
      1) If I extract the code that calls @CreateProcess to a separate method the jbpm process "acts" like a async process and needs a signal to start
      public String logmein()
      {
      createSyncProcess();
      }

      @CreateProcess(definition="asyncProcess")
      private createSyncProcess() {
      }

      In this case the pageflow continues, old values are shown on the page and process never kicksoff!

      Any info would be appreciated.