You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Luca Fossato <lu...@gmail.com> on 2008/04/18 14:39:29 UTC

[T5] way to check if the application is entering or exiting from a page

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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] way to check if the application is entering or exiting from a page

Posted by Luca Fossato <lu...@gmail.com>.
Hi Geoff,

yes, I read those threads and I modeled my CRUD page using the 
suggestions listed on your Mk VI page. Thank you.

As I was trying to explain to Jonathan Barker in my previous mail (ah, 
my poor english ;^) , my CRUD page already used @Persist("flash") to 
store the entity to modify.

The problem was I was trying to do "too much things" in a single page 
thinking that the flash persistence could do the job (well, it works 
fine, but I had some conditions that were not compatible with that kind 
of persistence strategy).

Anyway, I'm going to study Tapestry JumpStart to better understand T5 
behaviour and page lifecycle.

Regards,
Luca


Geoff Callender wrote:

> 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
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] way to check if the application is entering or exiting from a page

Posted by Geoff Callender <ge...@gmail.com>.
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 <chris_lewis@bellsouth.net 
> > 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: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>
>>
>> --
>> http://thegodcode.net
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] way to check if the application is entering or exiting from a page

Posted by Chris Lewis <ch...@bellsouth.net>.
I'm sorry but I'm a bit confused by the terminology. I'm not a T4 user
and the only thing I know about "rewind" is that it does not exist in
T5. If you want to initialize business data, onActivate is the place to
do it. If you want to handle form events, use event handlers to catch
them. If you want to execute something at the end of a request within
the context of the page, use pageDetached.

I apologize if I'm missing your point. Perhaps someone else can chime in.

chris

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 <ch...@bellsouth.net> 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: users-unsubscribe@tapestry.apache.org
>>  > For additional commands, e-mail: users-help@tapestry.apache.org
>>  >
>>  >
>>  >
>>
>>  --
>>  http://thegodcode.net
>>
>>
>>  ---------------------------------------------------------------------
>>  To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>  For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>   

-- 
http://thegodcode.net


RE: [T5] way to check if the application is entering or exiting from a page

Posted by Jonathan Barker <jo...@gmail.com>.
Luca,

I can see that the flash persistence strategy wouldn't quite work for you in
that case.

Actually, I'm doing something very similar, and I'm using regular session
persistence and manually clearing things when necessary. 

I think that the rewind phase would map closely to the split between
prepareForSubmit and prepareForRender for the form in terms of what you
would want to set up. 

As an aside, have you looked at the wiki page for a Hibernate grid model?
Depending on the size of your model, you might be better off with a model
that only retrieves a page at a time.  At some point, serializing that model
into the session has to get intensive.



Jonathan


> -----Original Message-----
> From: Luca Fossato [mailto:luca.fossato@gmail.com]
> Sent: Saturday, April 19, 2008 2:31 PM
> To: Tapestry users
> Subject: Re: [T5] way to check if the application is entering or exiting
> from a page
> 
> Hi Jonathan,
> 
> thank you for your suggestion.
> 
> Yes, @Persist("flash") works fine for one object of for a set of objects
>   that are always readed and showed into the page during the page
> rendering. And it's fine for a CRUD page that shows only the entity to
> manage.
> 
> To learn T5, I was sperimenting a CRUD page composed by:
> 
> 1) the list of objects to view / edit / delete rendered by the grid
> component. This list is alwasy visible.
> 
> 2) over the grid, a zone that shows the data of selected entity using
> BeanDisplay or BeanEditor, depending if the user clicks the "view" or
> the "edit" link of the selected grid row.
> 
> The entity data at #2 is displayed only if the user selects an entity
> from the above grid. When the user navigates the grid the application
> doesn't show any entity data.
> 
> My goal was to provide the user an unique page to show all the entities,
> to view an existant entity or to create a new one from the same page,
> without leaving it.
> I was using the flash persistence mechanism to store both the entity
> list managed by the grid and the single entity selected by the user.
> This to avoid to make other queries to the database to retrieve that
> data when the user executes an action on that page (on the "rewind"
> phase, as I call it - but it's not the correct term).
> 
> I noticed that when the application was not going to show a selected
> entity (#2), and the user selected another entity from the grid list,
> the application started to loose the "synchronization" between the
> grid's selected entity and the entity data showed below... it started to
> show the data of the old entity instead of the data of the new one.
> 
>  From my understanding, the value of a page property that uses
> @Persist("flash") is discarded from the session only after the
> application reads it to restore that property.
> So I think the old entity value was not discarded from the session
> because the application didn't show its data into the page.
> 
> Obviously, this was my code fault ;^) I fixed the problem removing the
> @Persist("flash") annotation on the selected entity property and
> refactoring a bit the db initialization code.
> 
> Luca
> 
> 
> Jonathan Barker wrote:
> > 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:luca.fossato@gmail.com]
> >> 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
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] way to check if the application is entering or exiting from a page

Posted by Luca Fossato <lu...@gmail.com>.
Hi Jonathan,

thank you for your suggestion.

Yes, @Persist("flash") works fine for one object of for a set of objects 
  that are always readed and showed into the page during the page 
rendering. And it's fine for a CRUD page that shows only the entity to 
manage.

To learn T5, I was sperimenting a CRUD page composed by:

1) the list of objects to view / edit / delete rendered by the grid 
component. This list is alwasy visible.

2) over the grid, a zone that shows the data of selected entity using 
BeanDisplay or BeanEditor, depending if the user clicks the "view" or 
the "edit" link of the selected grid row.

The entity data at #2 is displayed only if the user selects an entity 
from the above grid. When the user navigates the grid the application 
doesn't show any entity data.

My goal was to provide the user an unique page to show all the entities, 
to view an existant entity or to create a new one from the same page, 
without leaving it.
I was using the flash persistence mechanism to store both the entity 
list managed by the grid and the single entity selected by the user. 
This to avoid to make other queries to the database to retrieve that 
data when the user executes an action on that page (on the "rewind" 
phase, as I call it - but it's not the correct term).

I noticed that when the application was not going to show a selected 
entity (#2), and the user selected another entity from the grid list, 
the application started to loose the "synchronization" between the 
grid's selected entity and the entity data showed below... it started to 
show the data of the old entity instead of the data of the new one.

 From my understanding, the value of a page property that uses 
@Persist("flash") is discarded from the session only after the 
application reads it to restore that property.
So I think the old entity value was not discarded from the session 
because the application didn't show its data into the page.

Obviously, this was my code fault ;^) I fixed the problem removing the 
@Persist("flash") annotation on the selected entity property and 
refactoring a bit the db initialization code.

Luca


Jonathan Barker wrote:
> 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:luca.fossato@gmail.com]
>> 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

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: [T5] way to check if the application is entering or exiting from a page

Posted by Jonathan Barker <jo...@gmail.com>.
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:luca.fossato@gmail.com]
> 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 <ch...@bellsouth.net>
> 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: users-unsubscribe@tapestry.apache.org
> >  > For additional commands, e-mail: users-help@tapestry.apache.org
> >  >
> >  >
> >  >
> >
> >  --
> >  http://thegodcode.net
> >
> >
> >  ---------------------------------------------------------------------
> >  To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >  For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] way to check if the application is entering or exiting from a page

Posted by Josh Canfield <jo...@thedailytube.com>.
It sounds like what you are describing is @Persist("flash") which
stores the object in the session until the next time its read
(generally on the render pass)

You can also take a look at

http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry/ComponentResourcesCommon.html#isRendering()

Josh

On Fri, Apr 18, 2008 at 7:24 AM, Luca Fossato <lu...@gmail.com> 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 <ch...@bellsouth.net> 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: users-unsubscribe@tapestry.apache.org
> >  > For additional commands, e-mail: users-help@tapestry.apache.org
> >  >
> >  >
> >  >
> >
> >  --
> >  http://thegodcode.net
> >
> >
> >  ---------------------------------------------------------------------
> >  To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >  For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] way to check if the application is entering or exiting from a page

Posted by Luca Fossato <lu...@gmail.com>.
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 <ch...@bellsouth.net> 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: users-unsubscribe@tapestry.apache.org
>  > For additional commands, e-mail: users-help@tapestry.apache.org
>  >
>  >
>  >
>
>  --
>  http://thegodcode.net
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>  For additional commands, e-mail: users-help@tapestry.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] way to check if the application is entering or exiting from a page

Posted by Chris Lewis <ch...@bellsouth.net>.
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: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>   

-- 
http://thegodcode.net


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org