8 Replies Latest reply on Sep 1, 2006 4:25 AM by David G.

    Calling a @CreateProcess method

    David G. Newbie

      Hi, I'm trying to build a website with pageflows and process definitions (together).

      I have a method called withing a transition in the pageflow (like in the numberguess example app...).
      Inside this method, I want to create a new process instance (invoking the method with the @CreateProcess annotation), but the instance is never created.

      However, if I invoke that method (the one with @CreateProcess) from a button (like the TODO-list example), the process instance is created.
      I think the annotation isn't "interpreted" when the method is invoked manually.

      Thanks in advance :)

        • 1. Re: Calling a @CreateProcess method
          Pete Muir Master

          Can you post the relevant section of the session bean code?

          • 2. Re: Calling a @CreateProcess method
            David G. Newbie

            This is the bean invoked within the transition in the pageflow. The method "isMessageSent" is used to redirect (evaluate decision in pageflow) to different webpages if the message has been successfully sent.

            import org.jboss.seam.ScopeType;
            import org.jboss.seam.annotations.*;
            import org.jboss.seam.core.Actor;
            import org.jboss.seam.InterceptionType;
            
            @Name("contactAction")
            @Scope(ScopeType.EVENT)
            @Intercept(InterceptionType.ALWAYS)
            @Transactional
            public class ContactAction
            {
             @In(create=true)
             private Actor actor;
             private String name;
             private String email;
             private String message;
            
             @Out(scope=ScopeType.BUSINESS_PROCESS)
             private int messageId;
            
             private boolean messageSent;
            
             @Create
             @Begin(join=true, pageflow="Contact")
             public void begin()
             {
             messageSent = false;
             }
             public void sendMessage()
             {
             System.out.println("Hibernate...");
            
             messageSent = true; // hibernate doesn't fail, we suppose in the example....
            
             if (messageSent) startProcessDefinition();
            
             }
             @CreateProcess(definition="MessageContact")
             public void startProcessDefinition()
             {
             System.out.println("Creating process instance");
             // If this method is invoked from a button, perfect. But I want to create a process instance if the message is successfully sent (in sendMessage().
             }
             public boolean isMessageSent()
             {
             return messageSent;
             }
             public void doAction()
             {
             System.out.println("doAction!!");
             }
             public String getDescription()
             {
             return "Nuevo Mensaje";
             }
             @Destroy
             public void destroy()
             {
             System.out.println("Destroy");
             }
            
             public String getName() { return name; }
             public void setName(String name) { this.name = name; }
             public String getEmail() { return email; }
             public void setEmail(String email) { this.email = email; }
             public String getMessage() { return message; }
             public void setMessage(String message) { this.message = message; }
            }
            


            A solution could be:
            Add @CreateProcess to sendMessage() method, but I don't want a process instance to be created when the user sends a message.
            I want to create the process instance when the message is successfully sent, i mean, I want to decide its creation.

            Thanks for the replies.

            • 3. Re: Calling a @CreateProcess method
              Pete Muir Master

              Calls to this.methodName() aren't intercepted so the @CreateProcess annotation isn't used.

              • 4. Re: Calling a @CreateProcess method
                David G. Newbie

                And how could I create a process instance manually from sendMessage()?

                • 5. Re: Calling a @CreateProcess method
                  Pete Muir Master

                  After hunting through the source code

                  @In(create=true) BusinessProcess businessProcess;
                  businessProcess.createProcess("myProcessName");

                  or
                  BusinessProcess.instance().createProcess("processName");


                  • 6. Re: Calling a @CreateProcess method
                    David G. Newbie

                    I can't see the BusinessProcess class, only the BusinessProcessContext.
                    If I try to inject the businessProcessContext built-in seam component, it fails.

                    But businessProcessContext can't create process instances.

                    Thanks.

                    • 7. Re: Calling a @CreateProcess method
                      Pete Muir Master

                      Ah. I was at home and looking at the cvs head not at 1.0.1.GA. So if you want it either wait for 1.1 or grab cvs.

                      • 8. Re: Calling a @CreateProcess method
                        David G. Newbie

                        Thanks.
                        I'll wait for the new Seam version.