4 Replies Latest reply on May 2, 2011 12:04 PM by deyan none

    Flex 4: Module issues with mx AdvancedDataGrid

    deyan none

      HI there,

       

      I have a modular application. SDK is 4.5 Hero .

      The main app loads a module and receives UI components from it , which get displayed later.

       

      In general the component, returned from the module displays OK with both mx and spark components.

      However if I add AdvancedDataGrid  I get the exception:

      --------------------------------------------------

       

      TypeError: Error #1007: Instantiation attempted on a non-constructor.

      at mx.controls::AdvancedDataGridBaseEx/getSeparator()[E:\dev\hero_private_beta\frameworks\pr ojects\datavisualization\src\mx\controls\AdvancedDataGridBaseEx.as:4619]

      at mx.controls::AdvancedDataGridBaseEx/createHeaderSeparators()[E:\dev\hero_private_beta\fra meworks\projects\datavisualization\src\mx\controls\AdvancedDataGridBaseEx.as:4661]

      at mx.controls::AdvancedDataGrid/createHeaderSeparators()[E:\dev\hero_private_beta\framework s\projects\datavisualization\src\mx\controls\AdvancedDataGrid.as:2428]

      at mx.controls::AdvancedDataGridBaseEx/drawSeparators()[E:\dev\hero_private_beta\frameworks\ projects\datavisualization\src\mx\controls\AdvancedDataGridBaseEx.as:4575]

      at mx.controls::AdvancedDataGridBaseEx/updateDisplayList()[E:\dev\hero_private_beta\framewor ks\projects\datavisualization\src\mx\controls\AdvancedDataGridBaseEx.as:2120]

      at mx.controls::AdvancedDataGrid/updateDisplayList()[E:\dev\hero_private_beta\frameworks\pro jects\datavisualization\src\mx\controls\AdvancedDataGrid.as:2899]

      at mx.controls.listClasses::AdvancedListBase/validateDisplayList()[E:\dev\hero_private_beta\ frameworks\projects\datavisualization\src\mx\controls\listClasses\AdvancedListBase.as:3472 ]

      at mx.managers::LayoutManager/validateDisplayList()[E:\dev\hero_private_beta\frameworks\proj ects\framework\src\mx\managers\LayoutManager.as:719]

      at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\hero_private_beta\frameworks\pr ojects\framework\src\mx\managers\LayoutManager.as:778]

      at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\hero_private_beta\frame works\projects\framework\src\mx\managers\LayoutManager.as:1157]

      ---------------------------------

      Compiler option has -keep-all-type-selectors. It works fine with mx:DataGrid and all the other components for example, but not with AdvancedDataGrid.

      My app has the following structure:
      *** TestLibrary - a library app containing a single interface:
      test.IModuleComponent  
      Code:

      package test

      {

          import mx.core.UIComponent;

       

          public interface IModuleComponent

          {

              function getComponent() : UIComponent;

          }

      }

       

      *** TestModule - a module application, using TestLibrary as a RLS.

      Components:

       

      - test.module.TestModule.mxml

       

      <?xml version="1.0" encoding="utf-8"?>

      <mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009"

                 xmlns:s="library://ns.adobe.com/flex/spark"

                 xmlns:mx="library://ns.adobe.com/flex/mx" width="100%" height="100%"

                 implements="test.IModuleComponent" xmlns:module="test.module.*">

       

          <fx:Declarations>

              <!-- Place non-visual elements (e.g., services, value objects) here -->

          </fx:Declarations>

       

          <fx:Script>

              <![CDATA[

                  import mx.core.Application;

                  import mx.core.UIComponent;

       

                  import spark.components.Application;

       

                  import test.IInstanceFactory;

       

                  public function getComponent() : UIComponent {

                     return new TestComponent();

                  }

       

              ]]>

          </fx:Script>

       

          <s:VGroup width="100%" height="100%">

              <s:Label text="Test Module" />

              <module:TestComponent width="100%" height="100%" />

          </s:VGroup>   

      </mx:Module>

      - test.module.TestComponent.mxml

      <?xml version="1.0" encoding="utf-8"?>

      <s:VGroup xmlns:fx="http://ns.adobe.com/mxml/2009"

                                   xmlns:s="library://ns.adobe.com/flex/spark"

                                   xmlns:mx="library://ns.adobe.com/flex/mx"

                                   width="100%" height="100%">

          <fx:Declarations>

              <!-- Place non-visual elements (e.g., services, value objects) here -->

          </fx:Declarations>

       

          <fx:Script>

              <![CDATA[

                  import mx.collections.ArrayCollection;

                  [Bindable]

                  private var dpADG:ArrayCollection = new ArrayCollection([

                      {Artist:'Pavement', Album:'Slanted and Enchanted', Price:11.99},

                      {Artist:'Pavement', Album:'Brighten the Corners', Price:11.99},

                      {Artist:'Saner', Album:'A Child Once', Price:11.99},

                      {Artist:'Saner', Album:'Helium Wings', Price:12.99},

                      {Artist:'The Doors', Album:'The Doors', Price:10.99},

                      {Artist:'The Doors', Album:'Morrison Hotel', Price:12.99},

                      {Artist:'Grateful Dead', Album:'American Beauty', Price:11.99},

                      {Artist:'Grateful Dead', Album:'In the Dark', Price:11.99},

                      {Artist:'Grateful Dead', Album:'Shakedown Street', Price:11.99},

                      {Artist:'The Doors', Album:'Strange Days', Price:12.99},

                      {Artist:'The Doors', Album:'The Best of the Doors', Price:10.99}

                  ]);     

              ]]>

          </fx:Script>

              <s:Label text=" Test Data Grid" />

       

              <mx:AdvancedDataGrid

                  width="100%" height="100%"

                  sortExpertMode="true"

                  dataProvider="{dpADG}">

                  <mx:columns>

                      <mx:AdvancedDataGridColumn dataField="Artist" />

                      <mx:AdvancedDataGridColumn dataField="Album" />

                      <mx:AdvancedDataGridColumn dataField="Price" />

                  </mx:columns>

              </mx:AdvancedDataGrid> 

      </s:VGroup>

      -----------------------------------------
      TestComponent is used twice:
      1) in the module itself
      2) in getComponent() function , which comes from IModuleComponent interface.
      *** TestWebApp - the main web application.
      TestWebApp.mxml:

      <?xml version="1.0" encoding="utf-8"?>

      <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"

                     minWidth="955" minHeight="600">

          <fx:Declarations>

              <!-- Place non-visual elements (e.g., services, value objects) here -->

          </fx:Declarations>

       

       

          <fx:Script>

              <![CDATA[

                  import mx.charts.chartClasses.InstanceCache;

                  import mx.core.UIComponent;

       

                  import test.IModuleComponent;

                  private function onButtonClick() : void {

                      var app : IModuleComponent = testModule.child as IModuleComponent;

                      var testComponent : UIComponent = app.getComponent();

                      group.addElement( testComponent );

       

                  }

       

                  public function createInstance( instanceClass : Class ) : Object {

                      return new instanceClass();

                  }

              ]]>

          </fx:Script>

          <s:VGroup width="100%" height="100%" id="group">

              <mx:ModuleLoader id="testModule" url="../../TestModule/bin-debug/test/module/TestModule.swf"

                               height="100" width="100%"

                               applicationDomain="{ApplicationDomain.currentDomain }"/>

       

              <s:Button label="Click me !" click="onButtonClick()" />

          </s:VGroup>

      </s:Application>

      ---------------------------------------
      Initially when the web app is started the an AdvancedDataGrid ( coming from the ModuleLoader  tag, which loads TestModule, which contains TestComponent ) is displayed properly.
      When the button "Click me" is clicked - another TestComponent instance should be added into the VGroup.
      Instead the exception above appears.
      IF TestComponent contains mx:DataGrid or any other spark or MX component - everything works fine - the 2nd instance of TestComponent gets added.
      The issue occurs only with AdvancedDataGrid.
      I have enabled -keep-all-type-selectors  in TestWebApp, i tried all combinations of RLSs, merged libraries, external, etc - no chance.
      The issue reproduces with flex 4.1 and 4.5 burrito preview.
      I know it is a very specific issue ... but ... 
      we're trying to build a modular application in our company  ... and we want to use AdvancedDataGrid ( spark DataGrid is not ready yet ) so ... please help
      Thanks in advance,
      Deyan