I know it is a small problem, but when i go through the seam document (all 
documents,articles in the internet), I found all the action code actually has 
mixed responsibility: page navigation and business logic. See the following 
code from book demo:
@Stateless                                                                      
         (1)
@Name("register")
public class RegisterAction implements Register
{

   @In                                                                          
         (2)
   private User user;
   
   @PersistenceContext                                                          
         (3)
   private EntityManager em;
   
   @Logger                                                                      
         (4)
   private Log log;
   
   public String register()                                                     
         (5)
   {
      List existing = em.createQuery("select username from User where 
username=:username")
         .setParameter("username", user.getUsername())
         .getResultList();
         
      if (existing.size()==0)
      {
         em.persist(user);
         log.info("Registered new user #{user.username}");                      
         (6)
         return "/registered.jsp";                                              
         (7)
      }
      else
      {
         FacesMessages.instance().add("User #{user.username} already exists");  
         (8)
         return null;
      }
   }

}

the register function actually has dual resonsibility which broke a fundametal 
OO design principle:Single-Resonsibility-Principle. and all the generated seam 
code is same.

Would it be better that an official tutorial providing better sample code?

No offense. I do like SEAM.

Thanks

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

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3989590
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to