You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Programozás <pr...@hotmail.com> on 2004/03/25 16:06:57 UTC
prersistent property problem
Hello,
I have a component with a persistent property:
<property-specification name="tableState"
type="package.table.ITableState" initial-value="createTableState()"
persistent="yes" />
The problem is that the expression in the attribute "initial-value" is
executed on every page detach (from AbstractPage.detach()).
Why is it happening?
Norbi
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: prersistent property problem
Posted by =?...@tiger.tigra.hu,
_S=E1ndor=22?= <ty...@tigra.hu>.
> I would appriciate if someone would tell us that.
>
> As quickfix: you can create a property in the component class:
>
> private package.table.ITableState tableState;
> public package.table.ITableState getTableState() {
> if ( tableState == null ) {
> tableState = createTableState();
> }
> return tableState;
> }
>
> If you do not clear it explicitly in the cleanupAfterRender it will last
> "forever".
>
Ooops.
And of course it is not component persistent - it is component instance
persistent.
But if you make it static...
--
Irlanda, Sándor
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: prersistent property problem
Posted by =?...@tiger.tigra.hu,
_S=E1ndor=22?= <ty...@tigra.hu>.
I would appriciate if someone would tell us that.
As quickfix: you can create a property in the component class:
private package.table.ITableState tableState;
public package.table.ITableState getTableState() {
if ( tableState == null ) {
tableState = createTableState();
}
return tableState;
}
If you do not clear it explicitly in the cleanupAfterRender it will last
"forever".
> Then how should I define a component scope persistent property?
> Because my problem is that the property defined below won't be
> persistent.
>
> Thanks,
> Norbi
>
> ----- Original Message -----
> From: "Irlanda@tiger.tigra.hu, Sándor" <ty...@tigra.hu>
> To: "Tapestry users" <ta...@jakarta.apache.org>
> Sent: Thursday, March 25, 2004 4:31 PM
> Subject: Re: prersistent property problem
>
>
>> I believe it is the same pattern as cleanupAfterRender.
>>
>> When page gets detached it loses the connection to session. And you know
>> that persistent properties are session dependant.
>>
>>
>> On Thu, 25 Mar 2004 16:06:57 +0100, Programozás
>> <pr...@hotmail.com>
>> wrote:
>> > I have a component with a persistent property:
>> >
>> > <property-specification name="tableState"
>> > type="package.table.ITableState" initial-value="createTableState()"
>> > persistent="yes" />
>> >
>> > The problem is that the expression in the attribute "initial-value" is
>> > executed on every page detach (from AbstractPage.detach()).
>> > Why is it happening?
>> >
>> > Norbi
>>
>>
>>
>> --
>> Irlanda, Sándor
>>
>> ---------------------------------------------------------------------
>> 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
>
--
Irlanda, Sándor
TigraSoft Kft.
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: prersistent property problem
Posted by Programozás <pr...@hotmail.com>.
My problem is that its value is not restored from the session.
I will check for session invalidations...
Norbi
----- Original Message -----
From: "Mind Bridge" <mi...@yahoo.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Thursday, March 25, 2004 4:49 PM
Subject: RE: prersistent property problem
> It will be persistent.
>
> Keep in mind that a single page/component object can be used by a number
of
> people (sessions). In order to achieve that, at the end of the request
cycle
> a perstent property is stored in the session and then it is reinitialized.
> When at some point later the same session requests the page, the property
> will be loaded with the value stored in the session in the beginning of
the
> request cycle. As a result, from the view point of the page/component the
> property has retained its value and is persistent. If a new session is
> created, however, the property will have its initial value set to begin
> with.
>
> Finally, if the ognl expression you use for initial value is constant, it
> will be evaluated only once (e.g. if it is 'null' or 'true'). It is
> evaluated multiple times only if it is non-constant, e.g. 'new
ArrayList()'.
> Otherwise you will get a problem that a number of people have compained
> about in the past on this list.
>
> -----Original Message-----
> From: Programozás [mailto:programozas@hotmail.com]
> Sent: Thursday, March 25, 2004 5:37 PM
> To: Tapestry users
> Subject: Re: prersistent property problem
>
>
> Then how should I define a component scope persistent property?
> Because my problem is that the property defined below won't be persistent.
>
> Thanks,
> Norbi
>
> ----- Original Message -----
> From: "Irlanda@tiger.tigra.hu, Sándor" <ty...@tigra.hu>
> To: "Tapestry users" <ta...@jakarta.apache.org>
> Sent: Thursday, March 25, 2004 4:31 PM
> Subject: Re: prersistent property problem
>
>
> > I believe it is the same pattern as cleanupAfterRender.
> >
> > When page gets detached it loses the connection to session. And you know
> > that persistent properties are session dependant.
> >
> >
> > On Thu, 25 Mar 2004 16:06:57 +0100, Programozás
<pr...@hotmail.com>
> > wrote:
> > > I have a component with a persistent property:
> > >
> > > <property-specification name="tableState"
> > > type="package.table.ITableState" initial-value="createTableState()"
> > > persistent="yes" />
> > >
> > > The problem is that the expression in the attribute "initial-value" is
> > > executed on every page detach (from AbstractPage.detach()).
> > > Why is it happening?
> > >
> > > Norbi
> >
> >
> >
> > --
> > Irlanda, Sándor
> >
> > ---------------------------------------------------------------------
> > 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: prersistent property problem
Posted by Programozás <pr...@hotmail.com>.
I got it, it was my fault, sorry for the many mails :)
The problem was that my persistent property was not a primitive type but an
instance of a class.
In some of my listener methods I have modified this instance using it's
accessor methods, so Tapestry.fireObservedChange() has not been invoked
implicitly.
What is the best practise in this case? Is it OK if I pass the owner
component of the property to the property's constructor? Something like:
class ComplexPersistentPropertyType
{
public ComplexPersistentPropertyType(IComponent owner, String
propertyName)
{
this.owner = owner;
this.propertyName = propertyName;
}
...
public void setSomeProperty(int value)
{
this.someProperty = value;
Tapestry.fireObservedChange(this.owner, this.propertyName, this);
}
...
}
It does not seem to be very nice... :|
Thanks,
Norbi
----- Original Message -----
From: "Mind Bridge" <mi...@yahoo.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Thursday, March 25, 2004 4:49 PM
Subject: RE: prersistent property problem
> It will be persistent.
>
> Keep in mind that a single page/component object can be used by a number
of
> people (sessions). In order to achieve that, at the end of the request
cycle
> a perstent property is stored in the session and then it is reinitialized.
> When at some point later the same session requests the page, the property
> will be loaded with the value stored in the session in the beginning of
the
> request cycle. As a result, from the view point of the page/component the
> property has retained its value and is persistent. If a new session is
> created, however, the property will have its initial value set to begin
> with.
>
> Finally, if the ognl expression you use for initial value is constant, it
> will be evaluated only once (e.g. if it is 'null' or 'true'). It is
> evaluated multiple times only if it is non-constant, e.g. 'new
ArrayList()'.
> Otherwise you will get a problem that a number of people have compained
> about in the past on this list.
>
> -----Original Message-----
> From: Programozás [mailto:programozas@hotmail.com]
> Sent: Thursday, March 25, 2004 5:37 PM
> To: Tapestry users
> Subject: Re: prersistent property problem
>
>
> Then how should I define a component scope persistent property?
> Because my problem is that the property defined below won't be persistent.
>
> Thanks,
> Norbi
>
> ----- Original Message -----
> From: "Irlanda@tiger.tigra.hu, Sándor" <ty...@tigra.hu>
> To: "Tapestry users" <ta...@jakarta.apache.org>
> Sent: Thursday, March 25, 2004 4:31 PM
> Subject: Re: prersistent property problem
>
>
> > I believe it is the same pattern as cleanupAfterRender.
> >
> > When page gets detached it loses the connection to session. And you know
> > that persistent properties are session dependant.
> >
> >
> > On Thu, 25 Mar 2004 16:06:57 +0100, Programozás
<pr...@hotmail.com>
> > wrote:
> > > I have a component with a persistent property:
> > >
> > > <property-specification name="tableState"
> > > type="package.table.ITableState" initial-value="createTableState()"
> > > persistent="yes" />
> > >
> > > The problem is that the expression in the attribute "initial-value" is
> > > executed on every page detach (from AbstractPage.detach()).
> > > Why is it happening?
> > >
> > > Norbi
> >
> >
> >
> > --
> > Irlanda, Sándor
> >
> > ---------------------------------------------------------------------
> > 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
RE: prersistent property problem
Posted by Mind Bridge <mi...@yahoo.com>.
It will be persistent.
Keep in mind that a single page/component object can be used by a number of
people (sessions). In order to achieve that, at the end of the request cycle
a perstent property is stored in the session and then it is reinitialized.
When at some point later the same session requests the page, the property
will be loaded with the value stored in the session in the beginning of the
request cycle. As a result, from the view point of the page/component the
property has retained its value and is persistent. If a new session is
created, however, the property will have its initial value set to begin
with.
Finally, if the ognl expression you use for initial value is constant, it
will be evaluated only once (e.g. if it is 'null' or 'true'). It is
evaluated multiple times only if it is non-constant, e.g. 'new ArrayList()'.
Otherwise you will get a problem that a number of people have compained
about in the past on this list.
-----Original Message-----
From: Programozás [mailto:programozas@hotmail.com]
Sent: Thursday, March 25, 2004 5:37 PM
To: Tapestry users
Subject: Re: prersistent property problem
Then how should I define a component scope persistent property?
Because my problem is that the property defined below won't be persistent.
Thanks,
Norbi
----- Original Message -----
From: "Irlanda@tiger.tigra.hu, Sándor" <ty...@tigra.hu>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Thursday, March 25, 2004 4:31 PM
Subject: Re: prersistent property problem
> I believe it is the same pattern as cleanupAfterRender.
>
> When page gets detached it loses the connection to session. And you know
> that persistent properties are session dependant.
>
>
> On Thu, 25 Mar 2004 16:06:57 +0100, Programozás <pr...@hotmail.com>
> wrote:
> > I have a component with a persistent property:
> >
> > <property-specification name="tableState"
> > type="package.table.ITableState" initial-value="createTableState()"
> > persistent="yes" />
> >
> > The problem is that the expression in the attribute "initial-value" is
> > executed on every page detach (from AbstractPage.detach()).
> > Why is it happening?
> >
> > Norbi
>
>
>
> --
> Irlanda, Sándor
>
> ---------------------------------------------------------------------
> 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: prersistent property problem
Posted by Programozás <pr...@hotmail.com>.
Then how should I define a component scope persistent property?
Because my problem is that the property defined below won't be persistent.
Thanks,
Norbi
----- Original Message -----
From: "Irlanda@tiger.tigra.hu, Sándor" <ty...@tigra.hu>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Thursday, March 25, 2004 4:31 PM
Subject: Re: prersistent property problem
> I believe it is the same pattern as cleanupAfterRender.
>
> When page gets detached it loses the connection to session. And you know
> that persistent properties are session dependant.
>
>
> On Thu, 25 Mar 2004 16:06:57 +0100, Programozás <pr...@hotmail.com>
> wrote:
> > I have a component with a persistent property:
> >
> > <property-specification name="tableState"
> > type="package.table.ITableState" initial-value="createTableState()"
> > persistent="yes" />
> >
> > The problem is that the expression in the attribute "initial-value" is
> > executed on every page detach (from AbstractPage.detach()).
> > Why is it happening?
> >
> > Norbi
>
>
>
> --
> Irlanda, Sándor
>
> ---------------------------------------------------------------------
> 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: prersistent property problem
Posted by =?...@tiger.tigra.hu,
_S=E1ndor=22?= <ty...@tigra.hu>.
I believe it is the same pattern as cleanupAfterRender.
When page gets detached it loses the connection to session. And you know
that persistent properties are session dependant.
On Thu, 25 Mar 2004 16:06:57 +0100, Programozás <pr...@hotmail.com>
wrote:
> I have a component with a persistent property:
>
> <property-specification name="tableState"
> type="package.table.ITableState" initial-value="createTableState()"
> persistent="yes" />
>
> The problem is that the expression in the attribute "initial-value" is
> executed on every page detach (from AbstractPage.detach()).
> Why is it happening?
>
> Norbi
--
Irlanda, Sándor
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org