You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by William Keller <wi...@gmail.com> on 2004/08/04 03:43:18 UTC

Property initialisation executing twice

Hi all,
   This may sound like an infantile question and it's probably already
been covered - however my recent addition to this list is not helping
my cause :) The problem is, that I'm declaring a dynamic property in a
page like so:

    <property-specification name="story" 
        persistent="no"
        type="my.package..Story"
        initial-value="homeStory"
        />

So this calls the method "getHomeStory()" which is used many times
through out page. What I'm noticing however, is that for every hit to
the page, I'm getting the 'getHomeStory()' method executed twice. Is
this normal behaviour? Am I missing something trivial? I've been able
to get around it by testing the 'story' property (via abstract
methods) - but feel that this is unnecessary code. Can anyone explain
what's happening here?

I thank you all in advance!!

Cheers

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


Re: Property initialisation executing twice

Posted by William Keller <wi...@gmail.com>.
Thanks for the info! I'll probably stick to initialising dynamic stuff
using the 'IPageRenderListener' - and assign my simple objects using
initialisers.

Cheers!

On Wed, 4 Aug 2004 12:20:36 -0400, Howard Lewis Ship <hl...@gmail.com> wrote:
> This was a late change to Tapestry (the book isn't accurate here).
> 
> The OGNL expression provided in the initial-value attribute is
> evaluated when the page instance is first constructed, and *every
> time* the page is detached and returned to the pool.
> 
> Earlier version of Tapestry 3.0 would cache the value obtained at
> initialization and re-apply that value.  However, that didn't work
> well for mutable properties (i.e., it was fine for String and Integer,
> but lousy for HashMap or ArrayList or a custom object).
> 
> There's enough room to hang yourself there. You can access the engine
> and visit which is not completely kosher, in that you can end up
> recording state that is depenent on the client.  A page returned to
> pristine state should not have any client-specific values.
> 
> On Wed, 4 Aug 2004 11:43:18 +1000, William Keller
> 
> 
> <wi...@gmail.com> wrote:
> > Hi all,
> >    This may sound like an infantile question and it's probably already
> > been covered - however my recent addition to this list is not helping
> > my cause :) The problem is, that I'm declaring a dynamic property in a
> > page like so:
> >
> >     <property-specification name="story"
> >         persistent="no"
> >         type="my.package..Story"
> >         initial-value="homeStory"
> >         />
> >
> > So this calls the method "getHomeStory()" which is used many times
> > through out page. What I'm noticing however, is that for every hit to
> > the page, I'm getting the 'getHomeStory()' method executed twice. Is
> > this normal behaviour? Am I missing something trivial? I've been able
> > to get around it by testing the 'story' property (via abstract
> > methods) - but feel that this is unnecessary code. Can anyone explain
> > what's happening here?
> >
> > I thank you all in advance!!
> >
> > Cheers
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
> 
> --
> Howard M. Lewis Ship
> Independent J2EE / Open-Source Java Consultant
> Creator, Jakarta Tapestry
> Creator, Jakarta HiveMind
> http://howardlewisship.com
> 
> ---------------------------------------------------------------------
> 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: Property initialisation executing twice

Posted by Howard Lewis Ship <hl...@gmail.com>.
This was a late change to Tapestry (the book isn't accurate here).

The OGNL expression provided in the initial-value attribute is
evaluated when the page instance is first constructed, and *every
time* the page is detached and returned to the pool.

Earlier version of Tapestry 3.0 would cache the value obtained at
initialization and re-apply that value.  However, that didn't work
well for mutable properties (i.e., it was fine for String and Integer,
but lousy for HashMap or ArrayList or a custom object).

There's enough room to hang yourself there. You can access the engine
and visit which is not completely kosher, in that you can end up
recording state that is depenent on the client.  A page returned to
pristine state should not have any client-specific values.

On Wed, 4 Aug 2004 11:43:18 +1000, William Keller
<wi...@gmail.com> wrote:
> Hi all,
>    This may sound like an infantile question and it's probably already
> been covered - however my recent addition to this list is not helping
> my cause :) The problem is, that I'm declaring a dynamic property in a
> page like so:
> 
>     <property-specification name="story"
>         persistent="no"
>         type="my.package..Story"
>         initial-value="homeStory"
>         />
> 
> So this calls the method "getHomeStory()" which is used many times
> through out page. What I'm noticing however, is that for every hit to
> the page, I'm getting the 'getHomeStory()' method executed twice. Is
> this normal behaviour? Am I missing something trivial? I've been able
> to get around it by testing the 'story' property (via abstract
> methods) - but feel that this is unnecessary code. Can anyone explain
> what's happening here?
> 
> I thank you all in advance!!
> 
> Cheers
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


-- 
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Jakarta Tapestry
Creator, Jakarta HiveMind
http://howardlewisship.com

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