You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jorge Montero <jx...@imail.kwcorp.com> on 2007/05/04 00:49:58 UTC

[T4] Component initialization and PageBeginRender

I'm trying toconvert part of a tapestry page into a component for reuse. 
The part of the page I want to reuse renders two PropertySelectors with 
different data depending of the value of a property, and updates another 
property by processing the original property and the current values on 
the PropertySelectors. When this is part of the page, the filtering and 
creation of the models is done during pageBeginRender, and everything 
works fine.

My original plan was to just move the code over to the component's 
pageBeginRender(). The problem is that, as it is mentioned here ( 
http://wiki.apache.org/tapestry/Gotchas ), the component is not 
guaranteed to have received its parameters in pageBeginRender(), so the 
component might fail to initialize properly.

Is there any other way to initialize my component after the parameters 
have been populated?
Is there any other scheme that could make such a component work?

Jorge

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


Re: [T4] Component initialization and PageBeginRender

Posted by Jesse Kuhnert <jk...@gmail.com>.
Yeah, I would just move the logic out of pageBeginRender() and not do it at
all. Ie just let the properties flow naturally from whatever your parameters
are to your contained components. Tapestry should cache your models for you
as well so there's no point in second guessing things until you find a real
problem.

On 5/4/07, Jorge Montero <jx...@imail.kwcorp.com> wrote:
>
> First, thanks for the answer. It turns out a version upgrade improved
> things quite a bit: I just upgraded my ancient 4.0 distribution to 4.1,
> and now parameters are loaded before the pageBeginRender in  the
> component.
>
> The only problem I had with the upgrade was to find the apropriate
> replacement for requestCycle.getRequestContext().getRequest(): I wish
> that the injections that replace the call were mentioned in the javadoc.
> The rest of the upgrade was relatively painless.
>
> Unfortunately, the page's pageBeginRender is always called before the
> component's. This means I can't use the  from the component during page
> initialization, since they are not available yet.
>
> I could use pageValidateListener to do the component initalization,
> since it happens before page validation. I've already tried it, and it
> seems to work. Still, it feels like I'm twisting the lifecycle in ways
> that it was not supposed to be.
>
> Chances are that I just should just not use a component this way, but in
> this case, I think that the alternative is just some code duplication.
>
> Jorge.
>
>
> Jesse Kuhnert wrote:
>
> > I think that wiki page is out of date. MindBridge went in and made the
> > ordering deterministic a fairly long time ago.
> >
> > On 5/3/07, Jorge Montero <jx...@imail.kwcorp.com> wrote:
> >
> >>
> >> I'm trying toconvert part of a tapestry page into a component for
> reuse.
> >> The part of the page I want to reuse renders two PropertySelectors with
> >> different data depending of the value of a property, and updates
> another
> >> property by processing the original property and the current values on
> >> the PropertySelectors. When this is part of the page, the filtering and
> >> creation of the models is done during pageBeginRender, and everything
> >> works fine.
> >>
> >> My original plan was to just move the code over to the component's
> >> pageBeginRender(). The problem is that, as it is mentioned here (
> >> http://wiki.apache.org/tapestry/Gotchas ), the component is not
> >> guaranteed to have received its parameters in pageBeginRender(), so the
> >> component might fail to initialize properly.
> >>
> >> Is there any other way to initialize my component after the parameters
> >> have been populated?
> >> Is there any other scheme that could make such a component work?
> >>
> >> Jorge
> >>
> >> ---------------------------------------------------------------------
> >> 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
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

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

Re: [T4] Component initialization and PageBeginRender

Posted by Jorge Montero <jx...@imail.kwcorp.com>.
 First, thanks for the answer. It turns out a version upgrade improved 
things quite a bit: I just upgraded my ancient 4.0 distribution to 4.1, 
and now parameters are loaded before the pageBeginRender in  the component.

 The only problem I had with the upgrade was to find the apropriate 
replacement for requestCycle.getRequestContext().getRequest(): I wish 
that the injections that replace the call were mentioned in the javadoc. 
The rest of the upgrade was relatively painless.

Unfortunately, the page's pageBeginRender is always called before the 
component's. This means I can't use the  from the component during page 
initialization, since they are not available yet.

I could use pageValidateListener to do the component initalization, 
since it happens before page validation. I've already tried it, and it 
seems to work. Still, it feels like I'm twisting the lifecycle in ways 
that it was not supposed to be.

Chances are that I just should just not use a component this way, but in 
this case, I think that the alternative is just some code duplication.

Jorge.


Jesse Kuhnert wrote:

> I think that wiki page is out of date. MindBridge went in and made the
> ordering deterministic a fairly long time ago.
>
> On 5/3/07, Jorge Montero <jx...@imail.kwcorp.com> wrote:
>
>>
>> I'm trying toconvert part of a tapestry page into a component for reuse.
>> The part of the page I want to reuse renders two PropertySelectors with
>> different data depending of the value of a property, and updates another
>> property by processing the original property and the current values on
>> the PropertySelectors. When this is part of the page, the filtering and
>> creation of the models is done during pageBeginRender, and everything
>> works fine.
>>
>> My original plan was to just move the code over to the component's
>> pageBeginRender(). The problem is that, as it is mentioned here (
>> http://wiki.apache.org/tapestry/Gotchas ), the component is not
>> guaranteed to have received its parameters in pageBeginRender(), so the
>> component might fail to initialize properly.
>>
>> Is there any other way to initialize my component after the parameters
>> have been populated?
>> Is there any other scheme that could make such a component work?
>>
>> Jorge
>>
>> ---------------------------------------------------------------------
>> 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: [T4] Component initialization and PageBeginRender

Posted by Jesse Kuhnert <jk...@gmail.com>.
I think that wiki page is out of date. MindBridge went in and made the
ordering deterministic a fairly long time ago.

On 5/3/07, Jorge Montero <jx...@imail.kwcorp.com> wrote:
>
> I'm trying toconvert part of a tapestry page into a component for reuse.
> The part of the page I want to reuse renders two PropertySelectors with
> different data depending of the value of a property, and updates another
> property by processing the original property and the current values on
> the PropertySelectors. When this is part of the page, the filtering and
> creation of the models is done during pageBeginRender, and everything
> works fine.
>
> My original plan was to just move the code over to the component's
> pageBeginRender(). The problem is that, as it is mentioned here (
> http://wiki.apache.org/tapestry/Gotchas ), the component is not
> guaranteed to have received its parameters in pageBeginRender(), so the
> component might fail to initialize properly.
>
> Is there any other way to initialize my component after the parameters
> have been populated?
> Is there any other scheme that could make such a component work?
>
> Jorge
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

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