You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Kiran Meduri <mk...@gmail.com> on 2005/04/27 03:20:12 UTC

Initializing Persistent Property of a component

Hi,
  I have a page which contains a Tabbed Panel. And in one of the tabs
I have a component. This component inturn has 2 more components one
for view mode and one for edit mode. On the viewmode I have a property
for storing a list of items which is persistent. I have to initialize
this list using a function which takes arguments as a value of a
parameter of the component which is bound to a persistent property of
the page (via the parent component parameter).

here is the page file's property spec block

<property-specification name="objA" persistent="yes" type="A"/>

   <component id="parentComponent" type="ParentComponent">
       <binding name="objA" expression="objA"/>
   </component>

here is the parent component's property spec block

<parameter name="objA" required="yes" direction="in" type="A"/>

   <component id="editComponent" type="EditComponent">
        <binding name="objA" expression="objA"></binding>
   </component>
    <component id="viewComponent" type="ViewComponent">
        <binding name="objA" expression="objA"></binding>
    </component>

here is the view component's property spec block

<parameter name="objA" direction="in" required="yes" type="A"/>

<property-specification name="list" type="java.util.List"
       persistent="yes" initial-value="new java.util.ArrayList()">
   </property-specification>

In the JAVA file of view component I have a method initializeList()
which can initialize the values after reading from DB.

I have gone through the mailing list and found a solution which says
to call page.setup() methods to initialize properties before activate
which I dont want to do as there is only one page and the value of
objA comes from a different tab (component) on the same page.

Please suggest me of any solution.

--Thanks
mkk

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


Re: Initializing Persistent Property of a component

Posted by Kent Tong <ke...@cpttm.org.mo>.
Kiran Meduri <mkktapestry <at> gmail.com> writes:

> I have to initialize
> this list using a function which takes arguments as a value of a
> parameter of the component which is bound to a persistent property of
> the page (via the parent component parameter).

> <parameter name="objA" direction="in" required="yes" type="A"/>
> 
> <property-specification name="list" type="java.util.List"
>        persistent="yes" initial-value="new java.util.ArrayList()">
>    </property-specification>

Try overriding the prepareForRender() method in your view component.

void prepareForRender(IRequestCycle cycle) {
  super.prepareForRender(cycle);
  initializeList();
}



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