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]

Reply via email to