tapestry-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Howard Lewis Ship <hls...@gmail.com>
Subject Re: org.apache.tapestry5.runtime.ComponentEventException
Date Tue, 01 Mar 2011 21:04:24 GMT
On Tue, Mar 1, 2011 at 9:59 AM, robnangle <robnangle@gmail.com> wrote:
>
> 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.

Tapestry does some tricky things with bytecode transformation. Often,
it stops using your fields entirely, so what you see in the debugger
may not match what's really going on in the live code.  This is
somewhat fixed in trunk (5.3.0) and will be fixed in 5.2.5.


>>
>> 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-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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


Mime
View raw message