You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ron Piterman <rp...@gmx.net> on 2006/12/07 17:58:03 UTC

Re: @Persist and @InitialValue (followup)

Yes, it doesn't seem they work together - for me too... (on t4.0)
Cheers,
Ron

Dan Adams wrote:
> I've ran into a problem that other people seem to have reported on the
> mailing list before. But my unanswered question is: if you use @Persist
> and @InitialValue, when does the value get set back from the session?
> I've got the same problem someone else did where the property is set to
> the same value every time. Thanks.
> 
> 


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


Re: @Persist and @InitialValue (followup)

Posted by Ron Piterman <rp...@gmx.net>.
Usually I would implement another property which lazy-initializes this 
property.

However, this is impossible since persistant properties are not allowed 
to change during render.

What I do is: when I access the property from a component binding, I 
assume it could be null, so if it *may* *not* be null, I wrapp it inside 
some code: instead of "ognl:prop.name" I use ognl:propName and code a 
getter.

Inside listeners one might change the property, so I implement a lazy 
initialization access on each property:

getPropSafe() {
   if ( getProp() == null )
     setProp( initialValue );
   return getProp();
}

this method is only allowed to be used inside listeners.

Another method might be to initialize it manualy on pageValidate event - 
  or maybe even page BeginRender:

call
getPropSafe();

Cheers,
Ron






Dan Adams wrote:
> So, how do you set the initial value of a Persisted property to
> something non-trivial?
> 
> On Thu, 2006-12-07 at 17:58 +0100, Ron Piterman wrote:
> 
>>Yes, it doesn't seem they work together - for me too... (on t4.0)
>>Cheers,
>>Ron
>>
>>Dan Adams wrote:
>>
>>>I've ran into a problem that other people seem to have reported on the
>>>mailing list before. But my unanswered question is: if you use @Persist
>>>and @InitialValue, when does the value get set back from the session?
>>>I've got the same problem someone else did where the property is set to
>>>the same value every time. Thanks.
>>>
>>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>For additional commands, e-mail: users-help@tapestry.apache.org
>>


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


Re: Re: @Persist and @InitialValue (followup)

Posted by Sam Gendler <sg...@ideasculptor.com>.
Looking in my code, I never set the initial value of a persistent
property to something non-trivial - always null - so I can't help,
other than to offer the .page or .jwc file, since you can certainly do
it in there, or else to initialize without an annotation.  If you put
your init code in pageAttached(), it fires very early in the cycle and
only fires once for each request.  Unfortunately, it fires after tap
populates the property from the session (I think), so you'll have to
test for non-triviality before shoving a new value in it.

Or just fix the annotation, I suppose.

--sam

On 12/7/06, Dan Adams <da...@ifactory.com> wrote:
> So, how do you set the initial value of a Persisted property to
> something non-trivial?
>
> On Thu, 2006-12-07 at 17:58 +0100, Ron Piterman wrote:
> > Yes, it doesn't seem they work together - for me too... (on t4.0)
> > Cheers,
> > Ron
> >
> > Dan Adams wrote:
> > > I've ran into a problem that other people seem to have reported on the
> > > mailing list before. But my unanswered question is: if you use @Persist
> > > and @InitialValue, when does the value get set back from the session?
> > > I've got the same problem someone else did where the property is set to
> > > the same value every time. Thanks.
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> --
> Dan Adams
> Senior Software Engineer
> Interactive Factory
> 617.235.5857
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

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


Re: @Persist and @InitialValue (followup)

Posted by Dan Adams <da...@ifactory.com>.
So, how do you set the initial value of a Persisted property to
something non-trivial?

On Thu, 2006-12-07 at 17:58 +0100, Ron Piterman wrote:
> Yes, it doesn't seem they work together - for me too... (on t4.0)
> Cheers,
> Ron
> 
> Dan Adams wrote:
> > I've ran into a problem that other people seem to have reported on the
> > mailing list before. But my unanswered question is: if you use @Persist
> > and @InitialValue, when does the value get set back from the session?
> > I've got the same problem someone else did where the property is set to
> > the same value every time. Thanks.
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
-- 
Dan Adams
Senior Software Engineer
Interactive Factory
617.235.5857


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