You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by Oleg Konovalov <ol...@gmail.com> on 2014/05/19 18:29:04 UTC

Forced view init in ViewStack

Hi,

I have a ViewStack with a bunch of NavigationContent's, each of them having
a View, which contains at least one DataGrid or ADG.

Trying to implement a transition from one view to another programmatically,
so user selects a row in one DataGrid, and via right-mouse-click gets a
views selection,
which display related data (in another view).

It works overall in most cases,
but often I get into situation when that other view is not yet initialized,
it is still NULL, so user can't call any method related to that view, like
get a data from related service to populate that DataGrid.

Suppose I clicked on row in view1, and now trying to show related data in
view2.

1) Is there way to force creation/initialization of that view?
( I assume, doing   view2 = new MyView(params) is too low level
can't do view2.initialize() either since view2=null. )

2) Also even though the second view is displayed (doing
vs.selectedIndex=2),
in the menu on top of that page it still shows previous view selected.
How do I select correct menu item after displaying item2?


-- 
Thank you in advance,
Oleg.

Using Flex 4.5.1.

Re: Forced view init in ViewStack

Posted by Oleg Konovalov <ol...@gmail.com>.
Jason,

Your second suggestion worked like a charm...

As far as my question regarding changing menus in sync with viewstack
selected index, we are using 3rd party lib, so I figured it out.

Thanks a lot!
Oleg
On May 20, 2014 3:54 PM, "Jason Guild" <ja...@alaska.gov> wrote:

> Not sure, Oleg.
> Can you isolate it down to a small demo which shows the issue?
>
> On 5/20/2014 6:01 AM, Oleg Konovalov wrote:
>
>> Tried your immediate & default suggestion still gives me view2=NULL.
>> Will try to use view inside Declarations.
>>
>> Also how can I fix incorrect menu item selected after I set
>> vs.selected=index2?
>> On May 19, 2014 2:04 PM, "Jason Guild" <ja...@alaska.gov> wrote:
>>
>>  Hi Oleg:
>>>
>>> I don't recall ever encountering #2006.
>>>
>>> There is always an implicit "default" state AFAIK.
>>> You should be able to write itemCreationPolicy="immediate" with
>>> includeIn="default" no problem.
>>> I don't think any additional view states are necessary.
>>>
>>> Perhaps try declaring your various NavigationContent views in an
>>> <fx:Declarations> tag and then use actionscript to add them to the
>>> ViewStack in the creationComplete handler of the parent view which hosts
>>> the ViewStack?
>>>
>>> Also, NavigationContent was, I think, a hack to make Spark components
>>> work
>>> inside an mx:ViewStack. Maybe you are hitting some kind of edge case
>>> there.
>>>
>>> You could try using a Spark-based ViewStack like this one which does not
>>> need NavigationContent containers:
>>> http://custardbelly.com/downloads/viewstack/srcview/index.html
>>>
>>> HTH,
>>> Jason
>>>
>>> p.s. IMO, Apache Flex really needs an official spark-based ViewStack
>>> implementation.
>>>
>>> On 5/19/2014 9:46 AM, Oleg Konovalov wrote:
>>>
>>>  Jason, I tried that.
>>>>
>>>> It forced me to also add   includeIn  property (along with
>>>> itemCreationProperty) .
>>>> I had to create a few states (I didn't have any before) , including
>>>> State
>>>>    name="Immeriate"   and do:  includeIn="Immediate",
>>>> then I got error # 2006:  The supplied index is out of bounds  from
>>>> Spark
>>>> code...
>>>> How do I resolve that?
>>>>
>>>>
>>>>
>>>> On Mon, May 19, 2014 at 12:37 PM, Jason Guild <jason.guild@alaska.gov
>>>>
>>>>> wrote:
>>>>>
>>>>   Hi Oleg:
>>>>
>>>>> Try setting property:
>>>>> itemCreationPolicy="immediate"
>>>>>
>>>>> on the NavigationContent instances in your ViewStack that you need to
>>>>> be
>>>>> available sooner.
>>>>> Jason
>>>>>
>>>>>
>>>>> On 5/19/2014 8:29 AM, Oleg Konovalov wrote:
>>>>>
>>>>>   Hi,
>>>>>
>>>>>> I have a ViewStack with a bunch of NavigationContent's, each of them
>>>>>> having
>>>>>> a View, which contains at least one DataGrid or ADG.
>>>>>>
>>>>>> Trying to implement a transition from one view to another
>>>>>> programmatically,
>>>>>> so user selects a row in one DataGrid, and via right-mouse-click gets
>>>>>> a
>>>>>> views selection,
>>>>>> which display related data (in another view).
>>>>>>
>>>>>> It works overall in most cases,
>>>>>> but often I get into situation when that other view is not yet
>>>>>> initialized,
>>>>>> it is still NULL, so user can't call any method related to that view,
>>>>>> like
>>>>>> get a data from related service to populate that DataGrid.
>>>>>>
>>>>>> Suppose I clicked on row in view1, and now trying to show related data
>>>>>> in
>>>>>> view2.
>>>>>>
>>>>>> 1) Is there way to force creation/initialization of that view?
>>>>>> ( I assume, doing   view2 = new MyView(params) is too low level
>>>>>> can't do view2.initialize() either since view2=null. )
>>>>>>
>>>>>> 2) Also even though the second view is displayed (doing
>>>>>> vs.selectedIndex=2),
>>>>>> in the menu on top of that page it still shows previous view selected.
>>>>>> How do I select correct menu item after displaying item2?
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>

Re: Forced view init in ViewStack

Posted by Jason Guild <ja...@alaska.gov>.
Not sure, Oleg.
Can you isolate it down to a small demo which shows the issue?

On 5/20/2014 6:01 AM, Oleg Konovalov wrote:
> Tried your immediate & default suggestion still gives me view2=NULL.
> Will try to use view inside Declarations.
>
> Also how can I fix incorrect menu item selected after I set
> vs.selected=index2?
> On May 19, 2014 2:04 PM, "Jason Guild" <ja...@alaska.gov> wrote:
>
>> Hi Oleg:
>>
>> I don't recall ever encountering #2006.
>>
>> There is always an implicit "default" state AFAIK.
>> You should be able to write itemCreationPolicy="immediate" with
>> includeIn="default" no problem.
>> I don't think any additional view states are necessary.
>>
>> Perhaps try declaring your various NavigationContent views in an
>> <fx:Declarations> tag and then use actionscript to add them to the
>> ViewStack in the creationComplete handler of the parent view which hosts
>> the ViewStack?
>>
>> Also, NavigationContent was, I think, a hack to make Spark components work
>> inside an mx:ViewStack. Maybe you are hitting some kind of edge case there.
>>
>> You could try using a Spark-based ViewStack like this one which does not
>> need NavigationContent containers:
>> http://custardbelly.com/downloads/viewstack/srcview/index.html
>>
>> HTH,
>> Jason
>>
>> p.s. IMO, Apache Flex really needs an official spark-based ViewStack
>> implementation.
>>
>> On 5/19/2014 9:46 AM, Oleg Konovalov wrote:
>>
>>> Jason, I tried that.
>>>
>>> It forced me to also add   includeIn  property (along with
>>> itemCreationProperty) .
>>> I had to create a few states (I didn't have any before) , including
>>> State
>>>    name="Immeriate"   and do:  includeIn="Immediate",
>>> then I got error # 2006:  The supplied index is out of bounds  from Spark
>>> code...
>>> How do I resolve that?
>>>
>>>
>>>
>>> On Mon, May 19, 2014 at 12:37 PM, Jason Guild <jason.guild@alaska.gov
>>>> wrote:
>>>   Hi Oleg:
>>>> Try setting property:
>>>> itemCreationPolicy="immediate"
>>>>
>>>> on the NavigationContent instances in your ViewStack that you need to be
>>>> available sooner.
>>>> Jason
>>>>
>>>>
>>>> On 5/19/2014 8:29 AM, Oleg Konovalov wrote:
>>>>
>>>>   Hi,
>>>>> I have a ViewStack with a bunch of NavigationContent's, each of them
>>>>> having
>>>>> a View, which contains at least one DataGrid or ADG.
>>>>>
>>>>> Trying to implement a transition from one view to another
>>>>> programmatically,
>>>>> so user selects a row in one DataGrid, and via right-mouse-click gets a
>>>>> views selection,
>>>>> which display related data (in another view).
>>>>>
>>>>> It works overall in most cases,
>>>>> but often I get into situation when that other view is not yet
>>>>> initialized,
>>>>> it is still NULL, so user can't call any method related to that view,
>>>>> like
>>>>> get a data from related service to populate that DataGrid.
>>>>>
>>>>> Suppose I clicked on row in view1, and now trying to show related data
>>>>> in
>>>>> view2.
>>>>>
>>>>> 1) Is there way to force creation/initialization of that view?
>>>>> ( I assume, doing   view2 = new MyView(params) is too low level
>>>>> can't do view2.initialize() either since view2=null. )
>>>>>
>>>>> 2) Also even though the second view is displayed (doing
>>>>> vs.selectedIndex=2),
>>>>> in the menu on top of that page it still shows previous view selected.
>>>>> How do I select correct menu item after displaying item2?
>>>>>
>>>>>
>>>>>
>>>>>


Re: Forced view init in ViewStack

Posted by Oleg Konovalov <ol...@gmail.com>.
Tried your immediate & default suggestion still gives me view2=NULL.
Will try to use view inside Declarations.

Also how can I fix incorrect menu item selected after I set
vs.selected=index2?
On May 19, 2014 2:04 PM, "Jason Guild" <ja...@alaska.gov> wrote:

> Hi Oleg:
>
> I don't recall ever encountering #2006.
>
> There is always an implicit "default" state AFAIK.
> You should be able to write itemCreationPolicy="immediate" with
> includeIn="default" no problem.
> I don't think any additional view states are necessary.
>
> Perhaps try declaring your various NavigationContent views in an
> <fx:Declarations> tag and then use actionscript to add them to the
> ViewStack in the creationComplete handler of the parent view which hosts
> the ViewStack?
>
> Also, NavigationContent was, I think, a hack to make Spark components work
> inside an mx:ViewStack. Maybe you are hitting some kind of edge case there.
>
> You could try using a Spark-based ViewStack like this one which does not
> need NavigationContent containers:
> http://custardbelly.com/downloads/viewstack/srcview/index.html
>
> HTH,
> Jason
>
> p.s. IMO, Apache Flex really needs an official spark-based ViewStack
> implementation.
>
> On 5/19/2014 9:46 AM, Oleg Konovalov wrote:
>
>> Jason, I tried that.
>>
>> It forced me to also add   includeIn  property (along with
>> itemCreationProperty) .
>> I had to create a few states (I didn't have any before) , including
>> State
>>   name="Immeriate"   and do:  includeIn="Immediate",
>> then I got error # 2006:  The supplied index is out of bounds  from Spark
>> code...
>> How do I resolve that?
>>
>>
>>
>> On Mon, May 19, 2014 at 12:37 PM, Jason Guild <jason.guild@alaska.gov
>> >wrote:
>>
>>  Hi Oleg:
>>>
>>> Try setting property:
>>> itemCreationPolicy="immediate"
>>>
>>> on the NavigationContent instances in your ViewStack that you need to be
>>> available sooner.
>>> Jason
>>>
>>>
>>> On 5/19/2014 8:29 AM, Oleg Konovalov wrote:
>>>
>>>  Hi,
>>>>
>>>> I have a ViewStack with a bunch of NavigationContent's, each of them
>>>> having
>>>> a View, which contains at least one DataGrid or ADG.
>>>>
>>>> Trying to implement a transition from one view to another
>>>> programmatically,
>>>> so user selects a row in one DataGrid, and via right-mouse-click gets a
>>>> views selection,
>>>> which display related data (in another view).
>>>>
>>>> It works overall in most cases,
>>>> but often I get into situation when that other view is not yet
>>>> initialized,
>>>> it is still NULL, so user can't call any method related to that view,
>>>> like
>>>> get a data from related service to populate that DataGrid.
>>>>
>>>> Suppose I clicked on row in view1, and now trying to show related data
>>>> in
>>>> view2.
>>>>
>>>> 1) Is there way to force creation/initialization of that view?
>>>> ( I assume, doing   view2 = new MyView(params) is too low level
>>>> can't do view2.initialize() either since view2=null. )
>>>>
>>>> 2) Also even though the second view is displayed (doing
>>>> vs.selectedIndex=2),
>>>> in the menu on top of that page it still shows previous view selected.
>>>> How do I select correct menu item after displaying item2?
>>>>
>>>>
>>>>
>>>>
>>
>

Re: Forced view init in ViewStack

Posted by Jason Guild <ja...@alaska.gov>.
Hi Oleg:

I don't recall ever encountering #2006.

There is always an implicit "default" state AFAIK.
You should be able to write itemCreationPolicy="immediate" with 
includeIn="default" no problem.
I don't think any additional view states are necessary.

Perhaps try declaring your various NavigationContent views in an 
<fx:Declarations> tag and then use actionscript to add them to the 
ViewStack in the creationComplete handler of the parent view which hosts 
the ViewStack?

Also, NavigationContent was, I think, a hack to make Spark components 
work inside an mx:ViewStack. Maybe you are hitting some kind of edge 
case there.

You could try using a Spark-based ViewStack like this one which does not 
need NavigationContent containers:
http://custardbelly.com/downloads/viewstack/srcview/index.html

HTH,
Jason

p.s. IMO, Apache Flex really needs an official spark-based ViewStack 
implementation.

On 5/19/2014 9:46 AM, Oleg Konovalov wrote:
> Jason, I tried that.
>
> It forced me to also add   includeIn  property (along with
> itemCreationProperty) .
> I had to create a few states (I didn't have any before) , including   State
>   name="Immeriate"   and do:  includeIn="Immediate",
> then I got error # 2006:  The supplied index is out of bounds  from Spark
> code...
> How do I resolve that?
>
>
>
> On Mon, May 19, 2014 at 12:37 PM, Jason Guild <ja...@alaska.gov>wrote:
>
>> Hi Oleg:
>>
>> Try setting property:
>> itemCreationPolicy="immediate"
>>
>> on the NavigationContent instances in your ViewStack that you need to be
>> available sooner.
>> Jason
>>
>>
>> On 5/19/2014 8:29 AM, Oleg Konovalov wrote:
>>
>>> Hi,
>>>
>>> I have a ViewStack with a bunch of NavigationContent's, each of them
>>> having
>>> a View, which contains at least one DataGrid or ADG.
>>>
>>> Trying to implement a transition from one view to another
>>> programmatically,
>>> so user selects a row in one DataGrid, and via right-mouse-click gets a
>>> views selection,
>>> which display related data (in another view).
>>>
>>> It works overall in most cases,
>>> but often I get into situation when that other view is not yet
>>> initialized,
>>> it is still NULL, so user can't call any method related to that view, like
>>> get a data from related service to populate that DataGrid.
>>>
>>> Suppose I clicked on row in view1, and now trying to show related data in
>>> view2.
>>>
>>> 1) Is there way to force creation/initialization of that view?
>>> ( I assume, doing   view2 = new MyView(params) is too low level
>>> can't do view2.initialize() either since view2=null. )
>>>
>>> 2) Also even though the second view is displayed (doing
>>> vs.selectedIndex=2),
>>> in the menu on top of that page it still shows previous view selected.
>>> How do I select correct menu item after displaying item2?
>>>
>>>
>>>
>


Re: Forced view init in ViewStack

Posted by Oleg Konovalov <ol...@gmail.com>.
Jason, I tried that.

It forced me to also add   includeIn  property (along with
itemCreationProperty) .
I had to create a few states (I didn't have any before) , including   State
 name="Immeriate"   and do:  includeIn="Immediate",
then I got error # 2006:  The supplied index is out of bounds  from Spark
code...
How do I resolve that?



On Mon, May 19, 2014 at 12:37 PM, Jason Guild <ja...@alaska.gov>wrote:

> Hi Oleg:
>
> Try setting property:
> itemCreationPolicy="immediate"
>
> on the NavigationContent instances in your ViewStack that you need to be
> available sooner.
> Jason
>
>
> On 5/19/2014 8:29 AM, Oleg Konovalov wrote:
>
>> Hi,
>>
>> I have a ViewStack with a bunch of NavigationContent's, each of them
>> having
>> a View, which contains at least one DataGrid or ADG.
>>
>> Trying to implement a transition from one view to another
>> programmatically,
>> so user selects a row in one DataGrid, and via right-mouse-click gets a
>> views selection,
>> which display related data (in another view).
>>
>> It works overall in most cases,
>> but often I get into situation when that other view is not yet
>> initialized,
>> it is still NULL, so user can't call any method related to that view, like
>> get a data from related service to populate that DataGrid.
>>
>> Suppose I clicked on row in view1, and now trying to show related data in
>> view2.
>>
>> 1) Is there way to force creation/initialization of that view?
>> ( I assume, doing   view2 = new MyView(params) is too low level
>> can't do view2.initialize() either since view2=null. )
>>
>> 2) Also even though the second view is displayed (doing
>> vs.selectedIndex=2),
>> in the menu on top of that page it still shows previous view selected.
>> How do I select correct menu item after displaying item2?
>>
>>
>>
>


-- 
Thank you,
Oleg.

Re: Forced view init in ViewStack

Posted by Jason Guild <ja...@alaska.gov>.
Hi Oleg:

Try setting property:
itemCreationPolicy="immediate"

on the NavigationContent instances in your ViewStack that you need to be 
available sooner.
Jason

On 5/19/2014 8:29 AM, Oleg Konovalov wrote:
> Hi,
>
> I have a ViewStack with a bunch of NavigationContent's, each of them having
> a View, which contains at least one DataGrid or ADG.
>
> Trying to implement a transition from one view to another programmatically,
> so user selects a row in one DataGrid, and via right-mouse-click gets a
> views selection,
> which display related data (in another view).
>
> It works overall in most cases,
> but often I get into situation when that other view is not yet initialized,
> it is still NULL, so user can't call any method related to that view, like
> get a data from related service to populate that DataGrid.
>
> Suppose I clicked on row in view1, and now trying to show related data in
> view2.
>
> 1) Is there way to force creation/initialization of that view?
> ( I assume, doing   view2 = new MyView(params) is too low level
> can't do view2.initialize() either since view2=null. )
>
> 2) Also even though the second view is displayed (doing
> vs.selectedIndex=2),
> in the menu on top of that page it still shows previous view selected.
> How do I select correct menu item after displaying item2?
>
>