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:[EMAIL PROTECTED]
> 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:[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
> 
> ---------------------------------------------------------------------
> 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