[jboss-user] [JBoss Seam] - protected setter for a business key ?

c_inconnu do-not-reply at jboss.com
Mon Jul 30 08:19:11 EDT 2007


Hi,

I'd like to have a class like that :


  | @Entity
  | public class MyUser
  |     extends XXX
  | {
  |     private String login;
  | 
  |     protected MyUser()
  |     {
  |          // used by EJB3
  |     }
  | 
  |     public MyUser(String login)
  |     {
  |         this.setLogin(login);
  |     }
  | 
  |     public String getLogin()
  |     {
  |         return this.login;
  |     }
  | 
  |     protected void setLogin(String login)
  |     {
  |         this.login = login;
  |     }
  | }
  | 

ie. the setter for the immutable business key (login) is NOT public, which seems to be a good practice to me.

But in a user creation form, Seam requires the setter to be public in order to use #{user.login}. Is there some nice way to achieve this kind of encapsulation ?

Thanks,

David

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

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



More information about the jboss-user mailing list