You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Karthik N <ka...@gmail.com> on 2006/11/03 06:54:36 UTC

prepareForRender or pageBeginRender - which one should i use?

Hi,

I would like to do some initialization in a custom component that I'm
writing up.

I observe that I can do it in two ways:

1. Implement the PageBeginRenderListener and use pageBeginRender
2. Override prepareForRender

My question is: Which one should I use?

Thanks, Karthik

Re: prepareForRender or pageBeginRender - which one should i use?

Posted by Robert Zeigler <ro...@scazdl.org>.
prepareForRender is called every time a component is rendered.
So,for instance, if your component is in a for loop that is iterating
over 100 items, prepareForRender will be called 100 times.

pageBeginRender is called only once per page render and once per page
rewind. So if your component was in the middle of the aforementioned for
loop, pageBeginRender would still be called only once.

Depending on the type of initialization your component needs to do,
either one might be appropriate.  However, if you're using any complex
block trickery (ie blocks contained in page x are rendered in page y),
see: http://www.jroller.com/page/genjitsuteki for some risks of
pageBeginRender.

Robert

Karthik N wrote:
> Hi,
> 
> I would like to do some initialization in a custom component that I'm
> writing up.
> 
> I observe that I can do it in two ways:
> 
> 1. Implement the PageBeginRenderListener and use pageBeginRender
> 2. Override prepareForRender
> 
> My question is: Which one should I use?
> 
> Thanks, Karthik
> 


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