"So in your case the form in
tab one would throw a event up to the parent of the Tab Navigator where a
event handler can then set the properties in the secondary tab. "

Yeah... It's hard to know how to simplify an example for posting
sometimes... Tab 1 is dispatching a custom event full of VO.  It gets
to the parentApp, where an eventListener has been registered to pass
it to a handler.  The handler tries to set the values and properties
on Tab 2, and this is where I was hitting the null pointer exceptions.

"Your approach is basically the same as
creationPolicy="all". This maybe ok if 100% of your users will interact
directly with the secondary tabs. "

" It is in
this handler you could use createChildrenFromDescriptors() on the second
tab, then set the properties"

That makes pretty good sense to me, though I am in a position to
guarantee that 100% of the users will run the tabs in question.  Your
point is well taken, though.  Only bring up the children as they're
needed... put it in a conditional (tab2==null or something?) at the
top of the event handler that handles the assignment from tab 1 to tab
2.

I respectfully retract my earlier assertion that you were only
"partly" right!  ;)

(8(|)  - D'oh!

/w

On Thu, Aug 27, 2009 at 7:21 AM, Douglas
Knudsen<[email protected]> wrote:
>
> no, I'm quite right :)  I had written 'such as creationComplete', there are
> other useful events available too.  Your approach is basically the same as
> creationPolicy="all".  This maybe ok if 100% of your users will interact
> directly with the secondary tabs.
>
> " I need the selections on the first component (which is
> created when the tabNavigator is created) to set values into a form on
> the second component."
>
> This is alarming. Your component in Tab one should never reach out to a
> component in Tab two.  Use events to communicate data upwards.  Use
> injection to communicate properties downwards.  So in your case the form in
> tab one would throw a event up to the parent of the Tab Navigator where a
> event handler can then set the properties in the secondary tab.  It is in
> this handler you could use createChildrenFromDescriptors() on the second
> tab, then set the properties.  Or just set the selectedIndex and a anonymous
> function handler on creationComplete to inject the variables. Or heck, use
> binding!  Binding is great in these situations.
>
> Jeffry Houser has a nice preso around on Bullet Proofing your components
> that maybe useful here.  I don't have a link handy to the first part of this
> preso though, sorry.
>
> DK
>
> Douglas Knudsen
> http://www.cubicleman.com
> this is my signature, like it?
>
>
> On Wed, Aug 26, 2009 at 11:40 AM, Willy Ray <[email protected]> wrote:
>
>>
>> Hey DK,
>>
>> You're partly right.  In my example, I only had the two tabs, but in
>> my production app, I have many more, and they're all making REST calls
>> periodically once they've been created.  The creationPolicy idea was
>> perfect for my example... but not so good for my production problem.
>>
>> creationComplete, however isn't exactly the solution either, in this case.
>>
>> I have two UIComponents with lots of children, nested within a
>> tabNavigator.  I need the selections on the first component (which is
>> created when the tabNavigator is created) to set values into a form on
>> the second component.  Unfortunately, it isn't created until its tab
>> is clicked.  So... I could use it's creationComplete to go to the
>> first component, examine it, get the values I need, but then, when the
>> first component changed, I'd still need to have a method to set the
>> new values...
>>
>> The solution I've settled on, which I discovered on the same pages as
>> the creationPolicy documentation is the createChildrenFromDescriptors
>> method.  Basically:
>>
>> parentApplication.creationComplete(function (){
>>   mySecondComponent.createChildrenFromDescriptors();
>>   anyOthersIReallyNeed.createChildrenFromDescriptors();
>> };
>>
>> Does that seem reasonable?
>>
>> /willy
>>
>>
>> On Wed, Aug 26, 2009 at 9:29 AM, Douglas
>> Knudsen<[email protected]> wrote:
>> >
>> > exactly what you don't need actually. :)  Although that may work for you,
>> > its not a good practice as this turns off the deferred instantiation
>> > inherent to TabNavigator among others components.  This means that all
>> your
>> > tabs are created immediately regardless if they are ever viewed, slowing
>> > startup times.  Better to use other event such as creationComplete, etc.
>> >
>> > DK
>> >
>> > Douglas Knudsen
>> > http://www.cubicleman.com
>> > this is my signature, like it?
>> >
>> >
>> > On Mon, Aug 24, 2009 at 1:30 PM, Willy Ray <[email protected]> wrote:
>> >
>> >>
>> >> Oh Yes!  That's EXACTLY what I needed!  Thank you!
>> >>
>> >> /w
>> >>
>> >> On Mon, Aug 24, 2009 at 11:26 AM, <[email protected]> wrote:
>> >> >
>> >> > If I'm following you, I think you need to look into the creationPolity
>> >> > property.
>> >> >
>> >> >
>> >>
>> http://livedocs.adobe.com/flex/3/html/help.html?content=layoutperformance_05.html
>> >> >
>> >> > ~Brad
>> >> >
>> >> > -------- Original Message --------
>> >> >  Subject: Components in tabNavigator not initialized
>> >> >  From: Willy Ray <[email protected]>
>> >> >  Date: Mon, August 24, 2009 11:58 am
>> >> >  To: flex <[email protected]>
>> >> >
>> >> >
>> >> >  Hey guys,
>> >> >
>> >> >  Here's the issue:
>> >> >
>> >> >  I have a tabNavigator that basically looks like this:
>> >> >
>> >> >  My problem is that I need all the components in all the tabs to be
>> not
>> >> > null from the very beginning. I need, for example, to be able to set
>> >> > details.addEventListener() in the creationComplete function of the
>> >> > application... but details is NULL until it's been clicked on.
>> >> >
>> >> >  One way might be to refactor the creation of everything here into
>> >> > actionscript, but it would be a long and tedious refactoring, and I
>> >> > don't have the time. Thoughts?
>> >> >
>> >> >
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/flex/message.cfm/messageid:6061
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.37

Reply via email to