[jboss-user] [JBoss Seam] - Re: Adding Seam to an existing EJB2 application

kummer do-not-reply at jboss.com
Thu Sep 13 02:03:22 EDT 2007


The demoManager is created using seam-gen's new-conversation target. The xhtml page (as generated) has buttons for beginning and ending a conversation and for incrementing a value, which is shown on the page. The bean has the corresponding methods. Again, this is the raw product from the new-conversation target. Here is the code for the interface, the bean and the XHTML:

DemoManager.java


  | package lu.deka.tukan.session;
  | 
  | import javax.ejb.Local;
  | 
  | @Local
  | public interface DemoManager {  
  | 	
  | 	//seam-gen methods
  | 	public String begin();
  | 	public String increment();
  | 	public String end();
  | 	public int getValue();
  | 	public void destroy();
  | 	
  |    //add additional interface methods here	
  | }
  | 
  | 

DemoManagerBean.java


  | package lu.deka.tukan.session;
  | 
  | import javax.ejb.Remove;
  | import javax.ejb.Stateful;
  | import org.jboss.seam.annotations.Name;
  | import org.jboss.seam.annotations.Begin;
  | import org.jboss.seam.annotations.End;
  | import org.jboss.seam.annotations.Destroy;
  | import org.jboss.seam.annotations.Logger;
  | import org.jboss.seam.log.Log;
  | 
  | @Stateful
  | @Name("DemoManager")
  | public class DemoManagerBean implements DemoManager {
  | 	
  |    @Logger private Log log;
  |     
  |    private int value;
  | 	
  | 	@Begin
  | 	public String begin()
  | 	{
  | 		//implement your begin conversation business logic
  | 		log.info("beginning conversation");
  | 		return "success";
  | 	}
  | 	
  | 	public String increment()
  | 	{
  | 		log.info("incrementing");
  | 		value++;
  | 		return "success";
  | 	}
  | 	
  | 	//add additional action methods that participate in this conversation
  | 	
  | 	@End
  | 	public String end()
  | 	{
  |         //implement your end conversation business logic
  |         log.info("ending conversation");
  | 		return "home";
  | 	}
  | 	
  | 	public int getValue()
  | 	{
  | 		return value;
  | 	}
  | 	
  | 	@Destroy @Remove                                                                      
  | 	public void destroy() {}	
  | }
  | 

demoManager.xhtml


  | <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  |                              "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  | <ui:composition xmlns="http://www.w3.org/1999/xhtml"
  |                 xmlns:s="http://jboss.com/products/seam/taglib"
  |                 xmlns:ui="http://java.sun.com/jsf/facelets"
  |                 xmlns:f="http://java.sun.com/jsf"
  |                 xmlns:h="http://java.sun.com/jsf/html"
  |                 xmlns:rich="http://richfaces.ajax4jsf.org/rich"
  |                 template="layout/template.xhtml">
  |                        
  | <ui:define name="body">
  | 
  |     <h:messages globalOnly="true" styleClass="message"/>
  |     
  |     <rich:panel>
  |         <f:facet name="header">demoManager</f:facet>
  |             
  |         <div class="dialog">
  |             <div class="prop">
  |                 <span class="name">Value</span>
  |                 <span class="value">#{DemoManager.value}</span>
  |             </div>
  |         </div>
  |     
  |     </rich:panel>
  |     
  |     <h:form id="DemoManager">
  |         <div class="actionButtons">
  |             <h:commandButton id="begin" value="Begin" 
  |                 action="#{DemoManager.begin}"/>     			  
  |             <h:commandButton id="inc" value="Increment" 
  |                 action="#{DemoManager.increment}"/>     			  
  |             <h:commandButton id="end" value="End" 
  |                 action="#{DemoManager.end}"/>     			  
  |         </div>
  |     </h:form>
  |     
  | </ui:define>
  | 
  | </ui:composition>
  | 
  | 
  | 

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

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



More information about the jboss-user mailing list