0

I'm trying to work with GDS Tide framework. My basic code is this one :

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx"
               preinitialize="Tide.getInstance().initApplication()">

<fx:Script>
    <![CDATA[
        import controllers.TestController;

        import events.TestEvent;

        import models.TestModel;
        import models.interfaces.ITestModel;

        import mx.events.FlexEvent;

        import org.granite.tide.Tide;


        [Bindable][Inject]
        public var testModel:ITestModel;

        Tide.getInstance().addComponents([TestController, TestModel]);


    ]]>
</fx:Script>


<s:layout>
    <s:VerticalLayout />
</s:layout>

<s:Label text="{testModel.ab}" />
<s:Button click="dispatchEvent(new TestEvent());" label="test !" />

I can compile and run my code but when I'm launching my application, I see blank windows, my button or my label don't appear. No errors are fired.

When I change my code to this one :

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx"
               preinitialize="Tide.getInstance().initApplication()" creationComplete="application1_creationCompleteHandler(event)">

<fx:Script>
    <![CDATA[
        import controllers.TestController;

        import events.TestEvent;

        import models.TestModel;
        import models.interfaces.ITestModel;

        import mx.events.FlexEvent;

        import org.granite.tide.Tide;


        [Bindable][Inject]
        public var testModel:ITestModel;


        protected function application1_creationCompleteHandler(event:FlexEvent):void
        {
            Tide.getInstance().addComponents([TestController, TestModel]);
        }

    ]]>
</fx:Script>


<s:layout>
    <s:VerticalLayout />
</s:layout>

<s:Label text="{testModel.ab}" />
<s:Button click="dispatchEvent(new TestEvent());" label="test !" />

it works I see label and button but my label isn't initialized properly because my controller and model are added on mx.events.FlexEvent.CREATION_COMPLETE event.

What am I doing wrong please with the first (and recommanded) method ?

ketan
  • 19,129
  • 42
  • 60
  • 98
Olivier J.
  • 3,115
  • 11
  • 48
  • 71
  • Can I see how you have defined controller and model? Are you following https://www.granitedataservices.com/public/docs/2.3.2/docs/reference/en-US/html/graniteds.tideframework.html – gbdcool Dec 17 '14 at 02:03
  • Yes I followed docs. When I launch examples provided (and coded by GDS team) it's the same. When I use older GDS swc libraries (named granite-essential.swc) it's work. I don't understand why even if the workaround is just to use addComponents method in creationComplete event method. I don't understand why – Olivier J. Dec 17 '14 at 09:58
  • I'm not a GraniteDS expert, but it seems to me that in your first example, Tide's `addComponents` is being executed before `initApplication`. Is that deliberate? – Brian Dec 17 '14 at 20:20

0 Answers0