Components in tabNavigator not initialized

View: New views
7 Messages — Rating Filter:   Alert me  

Components in tabNavigator not initialized

by WillyRay :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hey guys,

Here's the issue:

I have a tabNavigator that basically looks like this:

<mx:TabNavigator id="tn" >
     <mx:Canvas id="masterListTab">
            <myComps:MasterList id="masterList"/>
     </mx:Canvas>
     <mx:Canvas id="detailTab">
          <myComps:Details id="details"/>
     </mx:Canvas>
</mx:TabNavigator>

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?

Thanks,

Willy

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:6040
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.37

Parent Message unknown RE: Components in tabNavigator not initialized

by Brad Wood-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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 <willyray@...>
 Date: Mon, August 24, 2009 11:58 am
 To: flex <flex@...>
 
 
 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:6041
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.37

Re: Components in tabNavigator not initialized

by WillyRay :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Oh Yes!  That's EXACTLY what I needed!  Thank you!

/w

On Mon, Aug 24, 2009 at 11:26 AM, <brad@...> 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 <willyray@...>
>  Date: Mon, August 24, 2009 11:58 am
>  To: flex <flex@...>
>
>
>  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:6042
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.37

Re: Components in tabNavigator not initialized

by Douglas Knudsen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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 <willyray@...> wrote:

>
> Oh Yes!  That's EXACTLY what I needed!  Thank you!
>
> /w
>
> On Mon, Aug 24, 2009 at 11:26 AM, <brad@...> 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 <willyray@...>
> >  Date: Mon, August 24, 2009 11:58 am
> >  To: flex <flex@...>
> >
> >
> >  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:6053
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.37

Re: Components in tabNavigator not initialized

by WillyRay :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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<douglasknudsen@...> 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 <willyray@...> wrote:
>
>>
>> Oh Yes!  That's EXACTLY what I needed!  Thank you!
>>
>> /w
>>
>> On Mon, Aug 24, 2009 at 11:26 AM, <brad@...> 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 <willyray@...>
>> >  Date: Mon, August 24, 2009 11:58 am
>> >  To: flex <flex@...>
>> >
>> >
>> >  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:6054
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.37

Re: Components in tabNavigator not initialized

by Douglas Knudsen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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 <willyray@...> 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<douglasknudsen@...> 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 <willyray@...> wrote:
> >
> >>
> >> Oh Yes!  That's EXACTLY what I needed!  Thank you!
> >>
> >> /w
> >>
> >> On Mon, Aug 24, 2009 at 11:26 AM, <brad@...> 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 <willyray@...>
> >> >  Date: Mon, August 24, 2009 11:58 am
> >> >  To: flex <flex@...>
> >> >
> >> >
> >> >  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:6056
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.37

Re: Components in tabNavigator not initialized

by WillyRay :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


"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<douglasknudsen@...> 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 <willyray@...> 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<douglasknudsen@...> 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 <willyray@...> wrote:
>> >
>> >>
>> >> Oh Yes!  That's EXACTLY what I needed!  Thank you!
>> >>
>> >> /w
>> >>
>> >> On Mon, Aug 24, 2009 at 11:26 AM, <brad@...> 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 <willyray@...>
>> >> >  Date: Mon, August 24, 2009 11:58 am
>> >> >  To: flex <flex@...>
>> >> >
>> >> >
>> >> >  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=17837.14401.37