1 Reply Latest reply on Jul 30, 2007 8:27 AM by Alex Ka

    protected setter for a business key ?

    David DIDIER Newbie


      I'd like to have a class like that :

      public class MyUser
       extends XXX
       private String login;
       protected MyUser()
       // used by EJB3
       public MyUser(String 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 ?



        • 1. Re: protected setter for a business key ?
          Alex Ka Novice

          I like the kind of encapsulation that you have showed but I think it does not correspond to the EJB standard. Maybe it can be used in custom classes.

          You really brake a lot of frameworks if you try to make the thing you showed in your code. I don't think Seam can help you if you do not cooperate with him, I mean if you do not stick to standards.

          I would be surprised if Seam provides a solution for this tweak.