tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Colin Sampaleanu <colin...@exis.com>
Subject Re: finishLoad() gets called in the wrong order (IMHO)
Date Thu, 21 Aug 2003 02:55:36 GMT
I think I am ok with using the PageRenderListener. My confusion stemmed 
from an incomplete understanding of the lifecycle.

I have pages and components which have some service/business interfaces 
set into them via property-specifications. Some other properties 
however, which ultimately get displayed on the page, need to be set via 
calls to the service interfaces. So I need to ensure that the Java code 
which sets this second set of properties executes after the tapestry 
framework code which sets the properties based on the 
property-specification.

I think I am totally ok in using the PageRenderListener to stick the 
java code initializing the second set of properties in the 
pageBeginRender method. At that point I have verified that the 
properties set by property-specification have been set already when that 
method is called, which makes sense.

I think other people will probably be doing this sort of two phase 
initialization of properties, so it may be worth mentioning specifically 
in the docs.

Regards,
Colin


Howard M. Lewis Ship wrote:

>Could you be a little more specific about what you are trying to accomplish?  Perhaps
we need yet
>another kind of event notification for your case.
>
>The PageDetachListener will not be called until the end of the request cycle, which I
suspect is too
>late.
>
>--
>Howard M. Lewis Ship
>Creator, Tapestry: Java Web Components
>http://jakarta.apache.org/tapestry
>
>
>
>  
>
>>-----Original Message-----
>>From: Colin Sampaleanu [mailto:colinml1@exis.com] 
>>Sent: Wednesday, August 20, 2003 6:20 PM
>>To: Tapestry development
>>Subject: Re: finishLoad() gets called in the wrong order (IMHO)
>>
>>
>>Hmm, after more investigation, I realize that things are not quite as 
>>they seem. finishLoad only gests called on the initial page load, and 
>>the createPropertyInitializers call is actually only setting 
>>up the prop 
>>initializers as a page detach listener.
>>
>>So what I think I need to do is have this component register 
>>itself as a 
>>page detach listener, and do the initialization there, right?
>>
>>
>>Colin Sampaleanu wrote:
>>
>>    
>>
>>>I have a big problem in that for a component, I am declaratively
>>>setting some properties via 'property-specification' elements with 
>>>initial values, then in finishLoad I need to set up some 
>>>      
>>>
>>other items 
>>    
>>
>>>based on the values that were set up by the property-specification. 
>>>However, property-sepcification values are set up by 
>>>      
>>>
>>tapestry _after_ 
>>    
>>
>>>the call to finishLoad()
>>>
>>>from PageLoader:
>>>           // Finish the load of the component; most 
>>>      
>>>
>>components (which
>>    
>>
>>>           // subclass BaseComponent) load their templates here.
>>>           // That may cause yet more components to be 
>>>      
>>>
>>created, and more
>>    
>>
>>>           // bindings to be set, so we defer some checking until
>>>           // later.
>>>
>>>           container.finishLoad(cycle, this, containerSpec);
>>>
>>>           // Finally, we create an initializer for each
>>>           // specified property.
>>>
>>>           createPropertyInitializers(page, container, 
>>>      
>>>
>>containerSpec);
>>    
>>
>>>Arguably, this should be reveresed, although there may be some
>>>negative implications for some other use cases that I don't 
>>>      
>>>
>>know of. 
>>    
>>
>>>What might be the best solution, and I can't think of any real 
>>>negatives, is to add another callback, let's call it 
>>>      
>>>
>>finishLoad2 for 
>>    
>>
>>>the purposes of this email, called after the call to 
>>>createPropertyInitializers.
>>>
>>>What does everybody think?
>>>
>>>Regards,
>>>Colin
>>>      
>>>




Mime
View raw message