You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by kranga <kr...@k2d2.org> on 2005/01/18 19:51:26 UTC

Are components reused? Help!

I've noticed that when I have a component in a Foreach loop, the same
component instance is reused to perform the rendering for each instance in
the loop. What is the general guideline for component reuse in Tapestry? Are
all component instances reused across users or are they only reused in cases
such as a Foreach loop rendering because there is just one instance of the
component defined?

Also, is the Form object instance that is used in the rewind phase the same
instance that is used in the render phase if the page were to redisplay
after the form post?


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


Re: Are components reused? Help!

Posted by kranga <kr...@k2d2.org>.
Jonathan,
    I think your description of the page behavior is correct. For
components, I have a strong suspicion that new instances are created for
every component defined. However, if a component such as Foreach causes its
body to be rendered multiple times, because the instances have already been
created for the components in the body of the foreach component, the same
instance execute the renderComponent each time.

Now the implication of this - how does this play out when I have a form
inside a foreach with validation delegates set. Since the delegate is only
defined once, the errors get written to all the forms!! yeah?

----- Original Message ----- 
From: "Jonathan Millett" <jo...@millett.net>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Tuesday, January 18, 2005 4:10 PM
Subject: Re: Are components reused? Help!


> kranga wrote:
>
> >Looks like everytime I ask this question, I get a conflicting answer. I
know
> >pages are pooled. Not sure about components.
> >
> >
> I'm not sure about components either.
>
> >Also, for a page, is the same page instance used in the rewind of a form
and
> >then subsequent rendering of the same page?
> >
> Yes.
>  It is the rewind stage that reads the submitted form parameters and
> updates your page's variables for later use in the render phase.
>
> > Is there any scenario where a
> >different page instance is used in the render cycle after a form post?
> >
> I don't think so.  This would invalidate the whole point of having a
> rewind phase.  The rewind and render happen in the same request cycle so
> there is no reason/need to go back to the pool.
>
>
> ---------------------------------------------------------------------
> 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: Are components reused? Help!

Posted by Jonathan Millett <jo...@millett.net>.
kranga wrote:

>Looks like everytime I ask this question, I get a conflicting answer. I know
>pages are pooled. Not sure about components.
>  
>
I'm not sure about components either.

>Also, for a page, is the same page instance used in the rewind of a form and
>then subsequent rendering of the same page?
>
Yes.
 It is the rewind stage that reads the submitted form parameters and 
updates your page's variables for later use in the render phase.

> Is there any scenario where a
>different page instance is used in the render cycle after a form post?
>
I don't think so.  This would invalidate the whole point of having a 
rewind phase.  The rewind and render happen in the same request cycle so 
there is no reason/need to go back to the pool.


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


Re: Are components reused? Help!

Posted by kranga <kr...@k2d2.org>.
Looks like everytime I ask this question, I get a conflicting answer. I know
pages are pooled. Not sure about components.

Also, for a page, is the same page instance used in the rewind of a form and
then subsequent rendering of the same page? Is there any scenario where a
different page instance is used in the render cycle after a form post? My
basic goal is to persist something between the rewind and render cycle. I
don't want Tapestry sticking it in the session because that would miserably
fail when dealing with multiple browsers and I don't want things in the
session if there is no need for it across requests (better clustering
performance).

----- Original Message ----- 
From: "Tom Klaasen" <ta...@tomk.be>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Tuesday, January 18, 2005 2:19 PM
Subject: Re: Are components reused? Help!


> As far as I know, all objects (pages, components) are pooled across the
> whole application. Thus it's not wise to store any state inside the
> components themselves. Let Tapestry keep track of state for you.
>
> hth,
> tomK
>
>
> kranga wrote:
>
> >I've noticed that when I have a component in a Foreach loop, the same
> >component instance is reused to perform the rendering for each instance
in
> >the loop. What is the general guideline for component reuse in Tapestry?
Are
> >all component instances reused across users or are they only reused in
cases
> >such as a Foreach loop rendering because there is just one instance of
the
> >component defined?
> >
> >Also, is the Form object instance that is used in the rewind phase the
same
> >instance that is used in the render phase if the page were to redisplay
> >after the form post?
> >
> >
> >---------------------------------------------------------------------
> >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
>


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


Re: Are components reused? Help!

Posted by Tom Klaasen <ta...@tomk.be>.
As far as I know, all objects (pages, components) are pooled across the 
whole application. Thus it's not wise to store any state inside the 
components themselves. Let Tapestry keep track of state for you.

hth,
tomK


kranga wrote:

>I've noticed that when I have a component in a Foreach loop, the same
>component instance is reused to perform the rendering for each instance in
>the loop. What is the general guideline for component reuse in Tapestry? Are
>all component instances reused across users or are they only reused in cases
>such as a Foreach loop rendering because there is just one instance of the
>component defined?
>
>Also, is the Form object instance that is used in the rewind phase the same
>instance that is used in the render phase if the page were to redisplay
>after the form post?
>
>
>---------------------------------------------------------------------
>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