I haven't used the @SessionState annotation, I use the
ApplicationStateManager directly to store SSOs but a quick look at the
docs suggest it's doing the same thing.

Firstly, I don't understand your User class - it seems to also contain a
User field? Sounds like a stackoverflow in the making....

Secondly, whatever object you're persisting as an SSO does not need it's
class annotated with @SessionState.

AFAIU tapestry will instantiate any SSO that you access if it's null
(you can override this behaviour). However of course any class fields
will be null unless they get instantiated in the default constructor
somehow.

A very simple login might look like this (ignoring things like hashing
passwords):

@SessionState(create=false)
private User user;

@Property
private String loginName;
@Propety
private String password;

@Inject
private UserDao userDao;

private String onSuccessFromLoginForm() {

    user = userDao.get(loginName);
   
    if (user != null && user.getPassword().equals(password) {
         return "PrivatePage";
    } else {
       user = null;  // if user is null not logged in
    }
    return null; // stay on login page
}

Now assuming the passwords matched, user should be non-null on other
pages.





On Tue, 2011-03-01 at 07:01 -0800, robnangle wrote:
> Richard Hill-7 wrote:
> > 
> > 
> > Getting the user id depends on what public methods your user object has.
> > Presumably it has something like .getId() ?
> > 
> > 
> > 
> > On Tue, 2011-03-01 at 06:44 -0800, robnangle wrote:
> >> Im probably wording the question wrong but that returns something like a
> >> memory address: Entities.User@12e7cb6
> >> 
> >> I want to find the user_id of that user?
> >> 
> > 
> > 
> > 
> > 
> > 
> 
> Yes I have a method like that but it keep's returning null, my user class:
> 
>          //These were originally strings but changed in an effort to get
> working
> 
>       @SessionState
>       private User user_id;
> 
>         public User getUser_id() {
>               return user_id;
>       }
> 
>       public void setUser_id(User user_id) {
>               this.user_id = user_id;
>       }
> 
> then the in my page:
> 
>         @SessionState
>       private User user;
> 
>         @Property
>       private String user_id;
> 
>         public User getUser() {
>               return user;
>       }
>       
>       public void setUser(User user) {
>               this.user = user;
>       }       
> 
>        prep.setString(1, user_id);
> 
> 
> 
> 
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to