Richard Hill-7 wrote:
> 
> 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.
> 

Yes the user is not null, as when I navigate from that page I display:

Logged in as: username

But the user_id still remains null for some reason.

Tryed setting it in the user constructor but no difference: 
user(string user_id) {
this.user_id = user_id;}


-- 
View this message in context: 
http://tapestry.1045711.n5.nabble.com/org-apache-tapestry5-runtime-ComponentEventException-tp3404853p3405407.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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

Reply via email to