Hi Luka,

It's probably best to ditch the mental model of "rewind" and "render" in T5. I think what you're after is covered in this thread on "Edit page best practice":

        http://thread.gmane.org/gmane.comp.java.tapestry.user/56176/focus=57580

It's discussed and demonstrated in Tapestry JumpStart:

        http://files.doublenegative.com.au/jumpstart/

Don't forget that action links throw a curved ball at your page: they cause a sequence of Action-Redirect-Render, so your onActivate() will probably get called twice before the page is displayed - once by the previous page's action handler method and then by the T5 framework after the redirect. The best practice above takes this into account. There's a JIRA issue that flowed from it too:

        https://issues.apache.org/jira/browse/TAPESTRY-2138

Cheers,

Geoff

On 19/04/2008, at 12:24 AM, Luca Fossato wrote:

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]

Reply via email to