You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Pillar <so...@hotmail.com> on 2012/11/26 21:45:14 UTC

SessionState

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? 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? Or are there other alternatives (not
necessarily for this use case, just having two instances of the same type in
session)?



--
View this message in context: http://tapestry.1045711.n5.nabble.com/SessionState-tp5718302.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


Re: SessionState

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Mon, 26 Nov 2012 19:17:45 -0200, Pillar <so...@hotmail.com> wrote:

> I don't know if it's common practice to send thank you's in a mailing  
> list, but screw it. Thanks! I'm pretty sure I'll be using much more of  
> Tapestry in the future.

We in the Tapestry mailing lists are very happy to help. :) Stick around  
and you'll notice many people providing very useful insights. ;)

-- 
Thiago H. de Paula Figueiredo

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


RE: SessionState

Posted by Pillar <so...@hotmail.com>.
I don't know if it's common practice to send thank you's in a mailing list, but screw it. Thanks! I'm pretty sure I'll be using much more of Tapestry in the future.

Sotirios

Date: Mon, 26 Nov 2012 13:08:55 -0800
From: ml-node+s1045711n5718303h14@n5.nabble.com
To: sotodel_89@hotmail.com
Subject: Re: SessionState



	On Mon, 26 Nov 2012 18:45:14 -0200, Pillar <[hidden email]> 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: [hidden email]

For additional commands, e-mail: [hidden email]




	
	
	
	

	

	
	
		If you reply to this email, your message will be added to the discussion below:
		http://tapestry.1045711.n5.nabble.com/SessionState-tp5718302p5718303.html
	
	
		
		To unsubscribe from SessionState, click here.

		NAML
	 		 	   		  



--
View this message in context: http://tapestry.1045711.n5.nabble.com/SessionState-tp5718302p5718304.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

Re: SessionState

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Mon, 26 Nov 2012 18:45:14 -0200, Pillar <so...@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-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org