[jboss-user] [JBoss Seam] - Re: Calling a @CreateProcess method

dgallego do-not-reply at jboss.com
Thu Aug 31 04:50:59 EDT 2006


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.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3968571#3968571

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3968571



More information about the jboss-user mailing list