Luca, Check the Form documentation for prepareForRender() and prepareForSubmit(). They can be better places to do heavy initialization than onActivate().
Also, take a look at @Persist("flash") which is meant to retain information for only one additional cycle (like the render after a form submit). You may find this is satisfactory for your "cache". Jonathan > -----Original Message----- > From: Luca Fossato [mailto:[EMAIL PROTECTED] > Sent: Friday, April 18, 2008 10:24 AM > To: Tapestry users > Subject: Re: [T5] way to check if the application is entering or exiting > from a page > > Hi Chris, > > thank you. > > Sorry, I didn't explain well. I intended from an "html page" point of > view. > Example: I have a page with a form. I'd like to track its lifecycle > both for the "rewind" and "render" phase > (I use T4 "rewind" term to indicate that the application is "exiting" > from a page, and "render" to indicate the application is entering into > the page) > > Here's an example log of the page lifecycle when I press the submit > button of its form: > > --- cut here --- > > >> page is rendered; click the submit button of the form: > > ====> [TRANSACTION] transaction begin... > myPage : pageAttached > myPage : onActivate > ** db initialization... > myPage : onSuccessFromForm > myPage: onPassivate (1 time) > <==== [TRANSACTION] closed the entity manager... > > myPage : pageDetached > > << form submit was successfull; T5 redirects to the same page; > > ====> [TRANSACTION] transaction begin... > myPage : pageAttached > myPage : onActivate > ** db initialization... > myPage: onPassivate (x times) > <==== [TRANSACTION] closed the entity manager... > > myPage : pageDetached > > --- cut here --- > > It seems to me that pageDetached is executed for both "rewind" and > "render" phases. > I'd like to know if there is an API or a strategy that I can use in > onActivate method (or another initialization method) to know if I am > exiting or entering the page. > > For example, I'd like to enter into a page and use onActivate() to > initialize business data from the db and store it into a cache > (session). > Then, when I press the submit button of the form contained into the > page, T5 will re-execute onActivate() again. > At that moment, I'd like to know if I am in the "rewind" phase. If so, > I could get the data from the cache (and then remove it from the > cache, too) > > When T5 re-enters into the page and re-executes onActivate() (3rd > time), I will check if the page is in "render" phase. > If so I will query the db again to get "fresh" data. > > Regards, > Luca > > > On Fri, Apr 18, 2008 at 2:46 PM, Chris Lewis <[EMAIL PROTECTED]> > wrote: > > Luca, > > > > I think what you want is the page life cyle method "PageDetached." See: > > http://tapestry.apache.org/tapestry5/tapestry-core/guide/lifecycle.html > > > > sincerely, > > chris > > > > > > > > Luca Fossato wrote: > > > Hi, > > > > > > in Tapestry 5 is there a way to determine if the application is > > > entering or exiting from a page (like the T4 api : > > > event.getRequestCycle().isRewinding() ) ? > > > > > > Thank you, > > > Luca > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > -- > > http://thegodcode.net > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]