Just a .02 clink... Alex is recommending a hallmark architectural pattern
for building an application from constituent parts
(http://tinyurl.com/9js2e). One of the hurdles in implementing this in Flex
has to deal with how creation policy plays with loosely tied models; if it
hasn¹t been touched yet ­ it doesn¹t exist, visual updates fail, and runtime
errors usually follow.

On a couple occasions I had to resort to have the template base listen for
any data changes on the model and when data change events fire ­ to pull
those changes local and update internal bindable variables that are used in
the template and drive the UI. Duplication you say? Yes... sadly there is
duplication involved.

Why do it this way? I¹ve found that no matter how Œlate¹ you try and capture
a data event... That there are times when controls like the view stack just
don¹t play nice. Fiddling with creationPolicy can help but doesn¹t address
the root cause. So... tight coupling within the template with loose coupling
to the model was a reasonable approach.

Rick Winscot


On 8/22/08 12:27 AM, "Alex Harui" <[EMAIL PROTECTED]> wrote:

>  
>  
> 
> creationCOmplete is a better bet, but pushing stuff into the template is
> potentially bad design.  It means you know something about the template and
> have broken encapsulation.  Other designs like model/view would have the
> template pull from a data model.  Other designs would have an interface to the
> template that abstracts what children do what.  That¹s how many of our
> components work and they use the lifecycle events and methods to validate
> properties ³later²
>  
> 
> 
> From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
> Of Richard Rodseth
> Sent: Thursday, August 21, 2008 2:28 PM
> To: [email protected]
> Subject: [flexcoders] Template architecture
>  
> 
> I'm prototyping a system where a view is built dynamically from an XML
> description (converted to VOs). The description refers to a template
> (hard-coded in MXML). The dynamic view observes the description (which is a
> part of its model) , and creates a child (the template) and adds it as a
> child. However, it also needs to "fill in" the template which involves
> accessing some of its children by id (eg. template["slot1"], template["slot2"]
> ).
> 
> If I construct the template via new Template1(), the children are not yet
> created. Their ids show up in the debugger, but the values are null. Should I
> add a listener for creationComplete, or is this a case where callLater() could
> be put to good effect?
>  
>     


Reply via email to