You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Peter Beshai <pe...@gmail.com> on 2008/04/08 16:51:26 UTC

[T5] Need AppPropertyEditBlocks to reload page-load values

I have a block in my AppPropertyEditBlocks that grabs a list of data from
the database, which works fine. The problem happens if I modify what should
be in that list (say I add another row to the db), the edit block doesn't
update it's list. I currently am populating the list in the pageLoaded
method:

void pageLoaded()
{
    _allCategories = _categoryDAO.findAll();
}

Any idea what I can do to fix this?

Peter Beshai

Re: [T5] Need AppPropertyEditBlocks to reload page-load values

Posted by Peter Beshai <pe...@gmail.com>.
Thanks Robert, I was unaware of the Cached annotation.

Peter

On Tue, Apr 8, 2008 at 11:13 AM, Robert Zeigler <ro...@scazdl.org> wrote:

> This is the expected behavior for pageLoaded. See:
>
> http://tapestry.apache.org/tapestry5/tapestry-core/apidocs/org/apache/tapestry/annotations/PageLoaded.html
> In particular:
> "This is useful for one-time component initializations..."
>
> How about using the @Cached annotation on the getAllCategories() method?
> I haven't used @Cached, personally, but my understanding of it is that it
> caches the results on first call to the method, for that particular request.
> On next request, the results will once again be refreshed, and the new
> results cached for that render.  You get the benefit of decreased overhead
> (you're not hitting the db every time getAllCategories() is called),
> and you still get the most up to date dataset.
>
> Cheers,
>
> Robert
>
>
> On Apr 8, 2008, at 4/810:01 AM , Peter Beshai wrote:
>
> > My current workaround it to just grab from the database on every
> > getAllCategories() call and get rid of the pageLoaded method. I'd be
> > interested to hear if there are any different approaches.
> >
> > Peter Beshai
> >
> > On Tue, Apr 8, 2008 at 10:51 AM, Peter Beshai <pe...@gmail.com>
> > wrote:
> >
> >  I have a block in my AppPropertyEditBlocks that grabs a list of data
> > > from
> > > the database, which works fine. The problem happens if I modify what
> > > should
> > > be in that list (say I add another row to the db), the edit block
> > > doesn't
> > > update it's list. I currently am populating the list in the pageLoaded
> > > method:
> > >
> > > void pageLoaded()
> > > {
> > >   _allCategories = _categoryDAO.findAll();
> > > }
> > >
> > > Any idea what I can do to fix this?
> > >
> > > Peter Beshai
> > >
> > >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: [T5] Need AppPropertyEditBlocks to reload page-load values

Posted by Robert Zeigler <ro...@scazdl.org>.
This is the expected behavior for pageLoaded. See:
http://tapestry.apache.org/tapestry5/tapestry-core/apidocs/org/apache/tapestry/annotations/PageLoaded.html
In particular:
"This is useful for one-time component initializations..."

How about using the @Cached annotation on the getAllCategories() method?
I haven't used @Cached, personally, but my understanding of it is that  
it caches the results on first call to the method, for that particular  
request.
On next request, the results will once again be refreshed, and the new  
results cached for that render.  You get the benefit of decreased  
overhead (you're not hitting the db every time getAllCategories() is  
called),
and you still get the most up to date dataset.

Cheers,

Robert

On Apr 8, 2008, at 4/810:01 AM , Peter Beshai wrote:
> My current workaround it to just grab from the database on every
> getAllCategories() call and get rid of the pageLoaded method. I'd be
> interested to hear if there are any different approaches.
>
> Peter Beshai
>
> On Tue, Apr 8, 2008 at 10:51 AM, Peter Beshai <pe...@gmail.com>
> wrote:
>
>> I have a block in my AppPropertyEditBlocks that grabs a list of  
>> data from
>> the database, which works fine. The problem happens if I modify  
>> what should
>> be in that list (say I add another row to the db), the edit block  
>> doesn't
>> update it's list. I currently am populating the list in the  
>> pageLoaded
>> method:
>>
>> void pageLoaded()
>> {
>>    _allCategories = _categoryDAO.findAll();
>> }
>>
>> Any idea what I can do to fix this?
>>
>> Peter Beshai
>>


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


RE: [T5] Need AppPropertyEditBlocks to reload page-load values

Posted by Jonathan Barker <jo...@gmail.com>.
pageLoaded() is something that may only happen once for many, many requests.

You might want to move it to pageAttached which will move it to per-request.
Also, check out the @Cached annotation that you could apply to the
getAllCategories() function if it is used more than once in a request.


> -----Original Message-----
> From: Peter Beshai [mailto:peter.beshai@gmail.com]
> Sent: Tuesday, April 08, 2008 11:01 AM
> To: Tapestry User Mailing List
> Subject: Re: [T5] Need AppPropertyEditBlocks to reload page-load values
> 
> My current workaround it to just grab from the database on every
> getAllCategories() call and get rid of the pageLoaded method. I'd be
> interested to hear if there are any different approaches.
> 
> Peter Beshai
> 
> On Tue, Apr 8, 2008 at 10:51 AM, Peter Beshai <pe...@gmail.com>
> wrote:
> 
> > I have a block in my AppPropertyEditBlocks that grabs a list of data
> from
> > the database, which works fine. The problem happens if I modify what
> should
> > be in that list (say I add another row to the db), the edit block
> doesn't
> > update it's list. I currently am populating the list in the pageLoaded
> > method:
> >
> > void pageLoaded()
> > {
> >     _allCategories = _categoryDAO.findAll();
> > }
> >
> > Any idea what I can do to fix this?
> >
> > Peter Beshai
> >


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


Re: [T5] Need AppPropertyEditBlocks to reload page-load values

Posted by Peter Beshai <pe...@gmail.com>.
My current workaround it to just grab from the database on every
getAllCategories() call and get rid of the pageLoaded method. I'd be
interested to hear if there are any different approaches.

Peter Beshai

On Tue, Apr 8, 2008 at 10:51 AM, Peter Beshai <pe...@gmail.com>
wrote:

> I have a block in my AppPropertyEditBlocks that grabs a list of data from
> the database, which works fine. The problem happens if I modify what should
> be in that list (say I add another row to the db), the edit block doesn't
> update it's list. I currently am populating the list in the pageLoaded
> method:
>
> void pageLoaded()
> {
>     _allCategories = _categoryDAO.findAll();
> }
>
> Any idea what I can do to fix this?
>
> Peter Beshai
>