Well, in the life cycle guide, it is said it could be used for
initializations or caching.
Actually, I have confirmed it could do that, but just it doesn't work to
retrieve and mutate persistent variables.
Cheers,
Jeffrey Ai
Michael Courcy wrote:
>
> I may be wrong as I'm a tapestry newbie, but pageAttached is something
> related to the compilation and pooling of the page template. Thus it
> should not deal with session buisness.
>
> jeffrey ai a écrit :
>> Hi Folks,
>>
>> I am looking for the best way to initialize a session variable(@Persist)
>> in
>> a page render request once, so I could access it in the next action
>> request.
>>
>> I tried to put the logic into "pageAttached" method like below:
>> ====
>> @Persist
>> private xxx myVar;
>>
>> @SuppressWarnings(value = "unused")
>> private void pageAttached()
>> {
>> if (myVar == null) initializeVar();
>> }
>> ====
>>
>> It doesn't work as I expected. myVar is always null in "pageAttached"
>> method. It seems the "pageAttached" method is not supposed to mutate a
>> persistent variable.
>>
>> However, if I put this logic into some other place like below, it works
>> fine.
>> ====
>> @Persist
>> private xxx myVar;
>>
>> public String getSomeOtherVar()
>> {
>> if (myVar == null) initializeVar();
>> return someOtherVar;
>> }
>> ====
>>
>> Although it works, apparently, this is not a good place.
>> Is there a better place to do session variable initialization?
>> I believe it should not be put into constructor too because it will be
>> viewable to other sessions.
>>
>> Thanks,
>> Jeffrey Ai
>>
>
>
> --
> Michael Courcy
> http://courcy.blogspot.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
--
View this message in context:
http://www.nabble.com/T5%3A-How-to-initialize-a-session-variable-in-a-page-render-request--tf4839139.html#a13861371
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]