On Mon, 26 Nov 2012 18:45:14 -0200, Pillar <sotodel...@hotmail.com> wrote:

Hi,

Hi!

In the Tapestry User Guide for  session storage
<http://tapestry.apache.org/session-storage.html>  , it states "Any other
component or page that declares a field of the same type, regardless of
name, and marks it with the SessionState annotation will share the same
value." I have the following Page class:

public class Page {
    @SessionState
    private User loggedInUser;
   @SessionState
    private User buddy;
}

Am I understanding correctly that both of these instances of User will be
the same?

Exactly the same. The actual name of the session attribute (which you should consider completely irrelevant) is based on the fully-qualified class name. The field name is ignored.

And that if I want them to be different, I have to encapsulate
them in another class, add an instance variable of that class to my Page
class, and annotate it as SessionState?

Yep. Or just create another class, for example, UserState, with two different fields, loggedInUser and buddy, and don't have an User in the @SessionState directly, so you have a single place for looking for the current logged in user.

I've been working with Tapestry 5 since the first alphas. @SessionState works exactly in the same way since then, almost 5 years ago. I've *never* needed two different instances of the same class in the session.

--
Thiago H. de Paula Figueiredo

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

Reply via email to