You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ted Steen <te...@gmail.com> on 2007/09/24 19:43:57 UTC

T5: Initial value for a field (persisted, parameter or just a plain field)

Hi all,

I define a field like this
private MyObject myObject = getDefaultMyObject();
Now, the default value is not set in the end of the request as documented.
If I put myObject in a form and alter fields within it, the values
will pop up in subsequent requests even from different clients(!).
This, I think, because the value is retained on the myObject field,
then returned to the page pool and reused later.

Am I supposed to reset the value in the end of the request? I though
it was automated.

-- 
/ted

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


Re: T5: Initial value for a field (persisted, parameter or just a plain field)

Posted by Ted Steen <te...@gmail.com>.
Ok,
So this means that
private MyObject myObject = new MyObject();
would not give me a new MyObject for every request? only a reference
to that object (that was created once at page creation time)
is this correct?
this means that I would need something like this in onActivate()
if (myObject == null)
{
  myObject = new MyObject();
}

2007/9/24, Josh Canfield <jo...@thedailytube.com>:
> It's working as specified.
>
> Tapestry automatically resets the value of your page attribute to what it
> was when the page object was first created. In this case, the value is
> whatever your method returned. It's not going to call your initialization
> method again.
>
> If you want your attribute to be different on every request then you should
> do that assignment in the onActivate or using the page lifecycle methods,
> attach/detach...
>
> Josh
>
>
> On 9/24/07, Ted Steen <te...@gmail.com> wrote:
> >
> > Hi all,
> >
> > I define a field like this
> > private MyObject myObject = getDefaultMyObject();
> > Now, the default value is not set in the end of the request as documented.
> > If I put myObject in a form and alter fields within it, the values
> > will pop up in subsequent requests even from different clients(!).
> > This, I think, because the value is retained on the myObject field,
> > then returned to the page pool and reused later.
> >
> > Am I supposed to reset the value in the end of the request? I though
> > it was automated.
> >
> > --
> > /ted
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
> --
> --
> TheDailyTube.com. Sign up and get the best new videos on the internet
> delivered fresh to your inbox.
>


-- 
/ted

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


Re: T5: Initial value for a field (persisted, parameter or just a plain field)

Posted by Josh Canfield <jo...@thedailytube.com>.
It's working as specified.

Tapestry automatically resets the value of your page attribute to what it
was when the page object was first created. In this case, the value is
whatever your method returned. It's not going to call your initialization
method again.

If you want your attribute to be different on every request then you should
do that assignment in the onActivate or using the page lifecycle methods,
attach/detach...

Josh


On 9/24/07, Ted Steen <te...@gmail.com> wrote:
>
> Hi all,
>
> I define a field like this
> private MyObject myObject = getDefaultMyObject();
> Now, the default value is not set in the end of the request as documented.
> If I put myObject in a form and alter fields within it, the values
> will pop up in subsequent requests even from different clients(!).
> This, I think, because the value is retained on the myObject field,
> then returned to the page pool and reused later.
>
> Am I supposed to reset the value in the end of the request? I though
> it was automated.
>
> --
> /ted
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.