Question

Flex Mobile Project I have a tabbed application with a http service. I would like to load the data, and once it is loaded pass it to the first tab, so the first tab can show a list with some data of the http service I would like to use the firstViewData property of the tab (as probably on the future I will send different data to each tab)

I have tried the following but I get no data on the view :-( On the main application

<?xml version="1.0" encoding="utf-8"?>
<s:TabbedViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                                  xmlns:s="library://ns.adobe.com/flex/spark"
                                  xmlns:wsdatos="services.wsdatos.*"
                                  creationComplete="tabbedviewnavigatorapplication1_creationCompleteHandler(event)"
                                  applicationDPI="160">
<fx:Script>
    <![CDATA[
        import mx.collections.ArrayCollection;
        import mx.events.FlexEvent;
        import mx.rpc.events.ResultEvent;

        public var WS:ArrayCollection;


        protected function operation1():void
        {
            Operation1Result.token = wSDatos.Operation1();
        }

        protected function tabbedviewnavigatorapplication1_creationCompleteHandler(event:FlexEvent):void
        {
            operation1();
        }

        protected function wSDatos_resultHandler(event:ResultEvent):void
        {
            WS = event.result as ArrayCollection;
        }

    ]]>
</fx:Script>

<s:ViewNavigator label="Home" width="100%" height="100%" firstView="views.HomeView" firstViewData="{WS}"/>
<s:ViewNavigator label="Publicidad" width="100%" height="100%" firstView="views.PublicidadView"/>
<s:ViewNavigator label="Eventos" width="100%" height="100%" firstView="views.EventosView"/>
<fx:Declarations>
    <s:CallResponder id="Operation1Result"/>
    <wsdatos:WSDatos id="wSDatos" result="wSDatos_resultHandler(event)"/>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
</s:TabbedViewNavigatorApplication>

On the home view

   <?xml version="1.0" encoding="utf-8"?>
   <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" title="Home">
    <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <s:List width="100%" height="100%" dataProvider="{data}" labelField="Nombre"/>
    </s:View>

I am just new in Flex so I am probably missing basic concepts... Any help on how to pass the data ?

The sample below works really fine on a not tabbed application, I just use navigator.pushView(views.HomeView event.result as ArrayCollection); on the function wSDatos_resultHandler (No need to use the var WS) So I am trying to do somehting similiar on a tabbed application Thanks!

Was it helpful?

Solution

One thing you'll need to do is mark your variable WS as [Bindable]. Without this, there is no notification sent when the data changes.

What's happening is that the view is created and the data from WS (initially unspecified) is used to display; then the HTTP request populates the WS return value, but since it's not marked Bindable the view isn't notified to update.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top