You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Kent Tong <ke...@cpttm.org.mo> on 2004/12/09 05:07:23 UTC

Bean lifecycles

Hi,

We can use the <bean> element to attach beans to a page. We can
also specify the lifecycle as none, page, request and render.
This is a lot of options. When should each one be used? I guess
what I am not understanding is that what problems this design
is trying solve.

Thanks!

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


Re: Bean lifecycles

Posted by Geoff Longman <gl...@gmail.com>.
clarification - lifecyle = page, the bean is initialized only once,
when the page instance is created.

Geoff


On Thu, 9 Dec 2004 15:40:54 -0500, Geoff Longman <gl...@gmail.com> wrote:
> If I recall correctly...
> 
> none - an instance of the bean is created and initialized every time
> you ask the page/component for it
> 
> page - the bean instance lives as long as the page instance (recall
> that many instances of the same page may be created and kept in a
> pool).
> 
> request - the bean instance lives throughout the length of the http
> request/response cycle.
> 
> render - a bean instance is created/intialized just before a render
> occurs. Recall that a rewind is also considered a render so the bean
> may be inited twice during one request cycle - once for the rewind and
> once for the final render.
> 
> The choice is up to you. When do you want to see a freshly initialized
> instance of the bean? Initing more often has a cost but it depends on
> your context.
> 
> Geoff
> 
> 
> 
> 
> On Thu, 09 Dec 2004 12:07:23 +0800, Kent Tong <ke...@cpttm.org.mo> wrote:
> > Hi,
> >
> > We can use the <bean> element to attach beans to a page. We can
> > also specify the lifecycle as none, page, request and render.
> > This is a lot of options. When should each one be used? I guess
> > what I am not understanding is that what problems this design
> > is trying solve.
> >
> > Thanks!
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
>

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


Re: Bean lifecycles

Posted by Geoff Longman <gl...@gmail.com>.
If I recall correctly...

none - an instance of the bean is created and initialized every time
you ask the page/component for it

page - the bean instance lives as long as the page instance (recall
that many instances of the same page may be created and kept in a
pool).

request - the bean instance lives throughout the length of the http
request/response cycle.

render - a bean instance is created/intialized just before a render
occurs. Recall that a rewind is also considered a render so the bean
may be inited twice during one request cycle - once for the rewind and
once for the final render.

The choice is up to you. When do you want to see a freshly initialized
instance of the bean? Initing more often has a cost but it depends on
your context.

Geoff




On Thu, 09 Dec 2004 12:07:23 +0800, Kent Tong <ke...@cpttm.org.mo> wrote:
> Hi,
> 
> We can use the <bean> element to attach beans to a page. We can
> also specify the lifecycle as none, page, request and render.
> This is a lot of options. When should each one be used? I guess
> what I am not understanding is that what problems this design
> is trying solve.
> 
> Thanks!
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
>

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