> > 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 can't tell you why pageAttached doesn't work (haven't tried it) but you can use onActivate, or if it's for a form onPrepare.
Josh On Nov 19, 2007 12:15 PM, jeffrey ai <[EMAIL PROTECTED]> wrote: > > 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 > -- > View this message in context: > http://www.nabble.com/How-to-initialize-a-session-variable-in-a-page-render-request--tf4839139.html#a13844361 > Sent from the Tapestry - User mailing list archive at > Nabble.com<http://nabble.com/> > . > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- -- TheDailyTube.com. Sign up and get the best new videos on the internet delivered fresh to your inbox.