[jboss-user] [JBoss Seam] - Seam promote bad design?

guanwh do-not-reply at jboss.com
Wed Nov 29 03:44:29 EST 2006

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)
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())
      if (existing.size()==0)
         log.info("Registered new user #{user.username}");                               (6)
         return "/registered.jsp";                                                       (7)
         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.


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

More information about the jboss-user mailing list