Typically, you would make this a transient, not a persistent property.

Set the property to null in initialize().  This gets invoked when the page is 
created, and when the page is detached (before being stored in the pool).

Then:

public List getDatabaseRows()
{
  if (_databaseRows == null) 
    _databaseRows = ... fetchFromDatabase ...

  return _databaseRows;
}

In other words, do it just as you need the data, and only if.  This is part of 
the "light touch" of Tapestry, and the kind of thing that gives Tapestry an 
edge on other frameworks, in my never-humble opinion.

Another option would be to override pageBeginRender() to perform the query.  If 
you do that, it can be either a transient or a persistent property 
(pageBeginRender is the last chance to invoke fireObservedChange(); after that 
fireObservedChange() will throw an exception).

The new documentation will have better examples for this kind of thing.  It's 
in progress now and will be one of the other key features of 2.4.

--
[EMAIL PROTECTED]

http://tapestry.sf.net
>       Thank you for your answer.
>       Certainly, I'm not implementing the initialize() method. In fact, the 
> data load is performed in the page attach method, because I didn't know where 
> should that behaviour be implemented. I thought that, each time the page is 
> accesed via the http browser, the attach method is invoked and the data loaded, 
> so the list would be up to data. The attach method is called (I'm sure about 
> that because a print messages on the console), so the data is correctly loaded 
> again, but the page seems to be rendered with dirty contents.
>       I solved the problem calling the fireObservedChange method of the list 
> page, but I still don't know if there is a good idea.
>       One more thing: is it ok to call setPage to implement the navigation?
>       Thanks again,
>               Dar�o
> 
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
> Sent: Monday, January 06, 2003 7:19 PM
> To: Dario A. Silva
> Cc: Tapestry Developer
> Subject: Re: [Tapestry-developer] page navigation
> 
> 
> I suspect what's happening is that you have read a list of rows from your 
> database into a collection and stored the collection as a property of your page.
> 
> The most likely culprit is that you are not implementing initialize:
> 
> public void initialize()
> {
>   _myDatabaseCollection = null;
> }
> 
> What happens is that one the first request cycle, it does the query.  You click 
> the delete link.  The same page instance comes out of the pool (cause there's 
> just one user) and the collection is filled in already.  Deleting the row from 
> the database doesn't affect the in-memory collection, so there it is.
> 
> A quick way to verify this is to turn caching off (see the FAQ).  You'll 
> probably see correct execution because you are guaranteed to get a new page 
> instance each request cycle.
> 
> 
> --
> [EMAIL PROTECTED]
> 
> http://tapestry.sf.net
> >     I have a simple page with a dynamic list (ie., a list with content 
> > extracted
> > from a db). Each row has its delete and update link (using DirectLink 
> > component).
> >     Update seems to work fine, since another page with a form to modify the 
> row 
> > is shown, and after submiting the page list appears up to date (with the 
> recent 
> > changes). The problem is the delete link: the list page is not updated. The 
> only 
> > difference is: in the first case, the navigation starts in the list page, then 
> > goes to the form page, and finally to the list page again; in the second case, 
> > only the page list is visited.
> >     After performing the action associated with a direct link, which is the 
> > proper manner to navigate to another page? and how can I force that page to be 
> > regenerated? (I mean, I don't want to navigate to a cached page).
> >     Thanks,
> >         Dar�o
> > 


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Tapestry-developer mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/tapestry-developer

Reply via email to