You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by leothelion <ok...@hotmail.com> on 2011/10/05 20:00:08 UTC

SessionState problem

Hi Guys,

I have a problem in using SessionState.

Here is the thing:
@SessionState
private Sales salesItem;

@SessionState
private SalesSessionInfo ssi;

SalesSessionInfo contains a list of Sales objects. However, every time when
I add the updated salesItem to ssi, it seems that the last element in the
Sales list of ssi is pointed the salesItem.

For example, I add salesItem A to ssi, then I have
[A] 
Add B, I got
[B, B]
Add C, I got
[B, C, C]

This is really weird. If I change salesItem back to like @property, it works
fine in adding, but not work for my purpose. I know SessionState is differed
by class, but in my case should I be OK?

Does anyone knows what I am missing in using SesstionState?

Regards,
Leo

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

Posted by leothelion <ok...@hotmail.com>.
I think I found where causes the problem.

Here is the tml file:

<t:grid source="AllSales" exclude="unitPriceNumber, vatNumber, totalNumber,
id" row="salesItem" add="action" reorder=" sku, desc, qty, freetext,
returnorsale, unitprice, vat, total">
	<p:skuCell>
		<t:actionlink t:id="edit"
context="salesItem.id">${salesItem.sku}</t:actionlink>
	</p:skuCell>
	...
        ...
</t:grid>

If I erase the ' row="salesItem" ', then the adding problem is gone. But I
cannot use a SessionState instance as a row in grid component? If not, what
is the alternative way to do so?
Anyone got any idea?

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

Posted by Lenny Primak <lp...@hope.nyc.ny.us>.
Tapestry objects's instance variables will never leak from user to user..
You have to try pretty hard to make that work.
Whether its' @Persist, @SessionState, @SessinoAttribute,
or just plain field, it will never leak.


On Oct 5, 2011, at 5:22 PM, leothelion wrote:

> Hi Thiago,
> 
> Thanks for your reply. I will try it. 
> 
> Just a question out of this topic. I use salesItem as SessionState is
> because I don't what it to be shared by the other users when they are
> loading the same page. That's why I came up with the idea of SessionState. I
> don't know if there another way (or easier way) other than setting salesItem
> to be SessionState.
> 
> Thanks again!
> 
> Leo
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/SessionState-problem-tp4873622p4874282.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
> 


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


Re: SessionState problem

Posted by leothelion <ok...@hotmail.com>.
Hi Thiago,

Thanks for your reply. I will try it. 

Just a question out of this topic. I use salesItem as SessionState is
because I don't what it to be shared by the other users when they are
loading the same page. That's why I came up with the idea of SessionState. I
don't know if there another way (or easier way) other than setting salesItem
to be SessionState.

Thanks again!

Leo

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

Posted by leothelion <ok...@hotmail.com>.
"If you did private SalesItem salesItem = new SalesItem()"
You got me!!!:-P
Thank you very much.

On 10/5/2011 3:12 PM, Thiago H de Paula Figueiredo [via Tapestry] wrote:
> On Wed, 05 Oct 2011 19:00:05 -0300, okramlee <[hidden email] 
> </user/SendEmail.jtp?type=node&node=4874465&i=0>> wrote:
>
> > Hi Thiago,
>
> Hi!
>
> > " If a field isn't @SessionState, it is completely thread-safe, not
> > being shared between users."
> > Yeah, that was what I thought about. But it did share the object 
> between
> > users even though I remove everything and keep salesItem plain there. I
> > think I did something wrong in my code.
>
> If you did private SalesItem salesItem = new SalesItem(), which is a
> common newbie error, that is expected. Never, never, never initialize a
> page or component field in its initialization.
>
> -- 
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email] 
> </user/SendEmail.jtp?type=node&node=4874465&i=1>
> For additional commands, e-mail: [hidden email] 
> </user/SendEmail.jtp?type=node&node=4874465&i=2>
>
>
>
> ------------------------------------------------------------------------
> If you reply to this email, your message will be added to the 
> discussion below:
> http://tapestry.1045711.n5.nabble.com/SessionState-problem-tp4873622p4874465.html 
>
> To unsubscribe from SessionState problem, click here 
> <http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4873622&code=b2tyYW1sZWVAaG90bWFpbC5jb218NDg3MzYyMnwtMTUxMjk1MDc4OQ==>. 
>



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