You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Alexander Lamb <Al...@rodanotech.ch> on 2007/05/27 16:20:41 UTC

Help needed for persistent properties initialization in components (4.1.2)

Hello list,

I am stuck with something.

I have a component which goes through several states. Therefore I  
need to keep some persistent properties.

That's why in the jwc file I have:

<property-specification name="registryCenter"  
type="ch.rodano.role.model.RegistryCenter" persistent="yes" />

However, I need to initialize some of those properties prior to the  
first rendering of the component.

I though I could do it in "prepareForRender(...)" I simply did a  
"setRegistryCenter(...)"

But it didn't work, I got the following message:

Persistent properties may only be changed prior to the rendering of  
the response page.

Where can I initialize my properties???

Thanks,
--
Alexander Lamb
Founding Associate
RODANOTECH Sàrl

26 ch des Tattes
1222 Vésenaz
Switzerland

Fax: 022 855 06 14

http://www.rodanotech.ch



Re: Help needed for persistent properties initialization in components (4.1.2)

Posted by Alexander Lamb <Al...@rodanotech.ch>.
Hello,

So if I understand correctly the two answers I received,

I should NOT use the initial-value attribute since I will not yet  
have session information (and probably component parameters).

If I need a place to initialize some persistent properties which will  
be called after the component parameters are set but before the  
component renders I need to implement pageBeginRender.

Alex

Le 28 mai 07 à 01:44, Christian Haselbach a écrit :

> On Sun, May 27, 2007 at 03:02:49PM -0400, Jesse Kuhnert wrote:
>> <property name="registryCenter" persist="session" initial- 
>> value="ognl: new
>> ch.mycompany.RegistryCenter()" />
>
> But it is important to keep in mind the semantics of initial-value. It
> is evaluated when the component is first created and when it _returns_
> to the pool (and not when it is fetched from the pool). Hence, if you
> write an initilization function that uses data from the current  
> session,
> you will not get what you expect.
>
> Regards,
> Christian
>
> -- 
> Christian Haselbach - christian.haselbach@tngtech.com - +49 176  
> 2082 5804
> TNG Technology Consulting GmbH, Betastr. 13a, 85774 Unterföhring
> Geschäftsführer: Henrik Klagges, Gerhard Müller, Eike Reinel
> Amtsgericht München, HRB 135082
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>

--
Alexander Lamb
Founding Associate
RODANOTECH Sàrl

26 ch des Tattes
1222 Vésenaz
Switzerland

Fax: 022 855 06 14

http://www.rodanotech.ch



Re: Help needed for persistent properties initialization in components (4.1.2)

Posted by Christian Haselbach <ch...@tngtech.com>.
On Sun, May 27, 2007 at 03:02:49PM -0400, Jesse Kuhnert wrote:
> <property name="registryCenter" persist="session" initial-value="ognl: new
> ch.mycompany.RegistryCenter()" />

But it is important to keep in mind the semantics of initial-value. It
is evaluated when the component is first created and when it _returns_
to the pool (and not when it is fetched from the pool). Hence, if you
write an initilization function that uses data from the current session,
you will not get what you expect.

Regards,
Christian

-- 
Christian Haselbach - christian.haselbach@tngtech.com - +49 176 2082 5804
TNG Technology Consulting GmbH, Betastr. 13a, 85774 Unterföhring
Geschäftsführer: Henrik Klagges, Gerhard Müller, Eike Reinel
Amtsgericht München, HRB 135082

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


Re: Help needed for persistent properties initialization in components (4.1.2)

Posted by Jesse Kuhnert <jk...@gmail.com>.
A few things:

-) property-specification is the old 3.0 dtd way of doing things, it should
look more like:

<property name="registryCenter" persist="session" />

-) There are two relatively easy ways to provide default values :

<property name="registryCenter" persist="session" initial-value="ognl: new
ch.mycompany.RegistryCenter()" />

or

implement PageBeginRenderListener in your component (the name of the
interface is unfortunate as it can be applied to any component - which pages
are themselves):

from http://tapestry.apache.org/tapestry4.1/usersguide/events.html  &&
http://tapestry.apache.org/tapestry4.1/apidocs/org/apache/tapestry/event/PageBeginRenderListener.html

public void pageBeginRender(PageEvent event)
{
    // initialize your property somehow
   setRegistryCenter(new RegistryCenter());
}

On 5/27/07, Alexander Lamb <Al...@rodanotech.ch> wrote:
>
> Hello list,
>
> I am stuck with something.
>
> I have a component which goes through several states. Therefore I
> need to keep some persistent properties.
>
> That's why in the jwc file I have:
>
> <property-specification name="registryCenter"
> type="ch.rodano.role.model.RegistryCenter" persistent="yes" />
>
> However, I need to initialize some of those properties prior to the
> first rendering of the component.
>
> I though I could do it in "prepareForRender(...)" I simply did a
> "setRegistryCenter(...)"
>
> But it didn't work, I got the following message:
>
> Persistent properties may only be changed prior to the rendering of
> the response page.
>
> Where can I initialize my properties???
>
> Thanks,
> --
> Alexander Lamb
> Founding Associate
> RODANOTECH Sàrl
>
> 26 ch des Tattes
> 1222 Vésenaz
> Switzerland
>
> Fax: 022 855 06 14
>
> http://www.rodanotech.ch
>
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com