Skip navigation
Chris_Hof
Currently Being Moderated

Flex 4 - Error with DataGrid in Module

Apr 2, 2010 7:23 AM

Hey, I'm using Flex 4 final and am now getting the following error when loading a Module with a DataGrid inside:

 

TypeError: Error #1009: Cannot access a property or method of a null object reference
    at mx.styles::StyleProtoChain$/initProtoChainForUIComponentStyleName()[E :\dev\4.0.0\frameworks\projects\framework\src\mx\styles\StyleProtoChai n.as:356]

 

It is created via MXML:

<mx:Module layout="absolute" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx">

    <mx:DataGrid>

        ... config etc.

    </mx:DataGrid>

    ... other code

</mx:Module>

 

If I remove the DataGrid the Module works fine. The code used to work in the various betas.

If I put a DataGrid in the main application that also renders fine, so it's only inside Modules.

 

Thanks in advance for any help or ideas!

 
Replies
  • Currently Being Moderated
    Apr 2, 2010 8:22 AM   in reply to Chris_Hof

    I suspect the problem is with how you are creating the module. Are you calling the module.factory.create() function like ModuleLoader does in moduleReadyHandler?

     

     

    -Darrell

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 3, 2010 4:26 AM   in reply to Chris_Hof

    I do not think that this is a bug, because I load modules which contains a datagrid successfully by using Module Manager. You can find an example on my playground. Every click on one of the buttons from the top navigation button bar will load and open a module.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 3, 2010 10:13 PM   in reply to Chris_Hof

    What error are you getting?

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 6, 2010 11:00 AM   in reply to Chris_Hof

    I'm going to take a guess at what the problem might be.

     

    It looks like the name of your module is "Benutzerverwaltung". Generate a link report for the application that contains the ModuleLoader of the module. Check the link report for the "Benutzerverwaltung" class. I suspect the class is there which means you are referencing the module from the application. Can you check if this true.

     

     

    -Darrell

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 22, 2010 7:17 AM   in reply to Darrell Loverin

    Hi Darrell,

         I have the exact same error, and yes I am using module.factory.create() but I get an error when I try to add the module to my stage.  Here it is the code in my modReady function.

     

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

    var _sd:Object = new Object();         

    _sd = util.app.SDModule.factory.create() as SequenceDetail;
                _sd.sequenceId = event.currentTarget.selectedItem.sequenceId;
                _sd.environment = event.currentTarget.selectedItem.environment;
                _sd.seqname = event.currentTarget.selectedItem.sequenceName;
                util.app.page.addChildAt(_sd as SequenceDetail, util.app.page.numChildren);
                util.app.nav_buttons.selectedIndex = -1;
                util.app.page.selectedIndex = util.app.page.numChildren-1;

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

     

    I get an error on util.app.page.addChildAt(........).

     

    error is

     

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

    TypeError: Error #1009: Cannot access a property or method of a null object reference.
        at mx.styles::StyleProtoChain$/initProtoChainForUIComponentStyleName()[E :\dev\4.0.0\frameworks\projects\framework\src\mx\styles\StyleProtoChai n.as:356]
        at mx.styles::StyleProtoChain$/initProtoChain()[E:\dev\4.0.0\frameworks\ projects\framework\src\mx\styles\StyleProtoChain.as:171]
        at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::initProtoChain()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent. as:10186]
        at mx.core::UIComponent/regenerateStyleCache()[E:\dev\4.0.0\frameworks\p rojects\framework\src\mx\core\UIComponent.as:10249]
        at mx.core::Container/regenerateStyleCache()[E:\dev\4.0.0\frameworks\pro jects\framework\src\mx\core\Container.as:3737]
        at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::addingChild()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent. as:7114]
        at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::rawChildren_addChild()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Container.as :4464]
        at mx.core::ContainerRawChildrenList/addChild()[E:\dev\4.0.0\frameworks\ projects\framework\src\mx\core\ContainerRawChildrenList.as:143]
        at mx.containers::TabNavigator/createChildren()[E:\dev\4.0.0\frameworks\ projects\framework\src\mx\containers\TabNavigator.as:559]
        at mx.core::UIComponent/initialize()[E:\dev\4.0.0\frameworks\projects\fr amework\src\mx\core\UIComponent.as:7250]
        at mx.core::Container/initialize()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\core\Container.as:3129]
        at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent. as:7142]
        at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Container.as :3951]
        at mx.core::Container/addChildAt()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\core\Container.as:2616]
        at mx.core::Container/addChild()[E:\dev\4.0.0\frameworks\projects\framew ork\src\mx\core\Container.as:2534]
        at mx.core::Container/createComponentFromDescriptor()[E:\dev\4.0.0\frame works\projects\framework\src\mx\core\Container.as:4371]
        at mx.core::Container/createComponentsFromDescriptors()[E:\dev\4.0.0\fra meworks\projects\framework\src\mx\core\Container.as:4160]
        at mx.containers::Panel/createComponentsFromDescriptors()[E:\dev\4.0.0\f rameworks\projects\framework\src\mx\containers\Panel.as:1685]
        at mx.core::Container/createChildren()[E:\dev\4.0.0\frameworks\projects\ framework\src\mx\core\Container.as:3187]
        at mx.containers::Panel/createChildren()[E:\dev\4.0.0\frameworks\project s\framework\src\mx\containers\Panel.as:1198]
        at mx.core::UIComponent/initialize()[E:\dev\4.0.0\frameworks\projects\fr amework\src\mx\core\UIComponent.as:7250]
        at mx.core::Container/initialize()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\core\Container.as:3129]
        at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent. as:7142]
        at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Container.as :3951]
        at mx.core::Container/addChildAt()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\core\Container.as:2616]
        at mx.core::Container/addChild()[E:\dev\4.0.0\frameworks\projects\framew ork\src\mx\core\Container.as:2534]
        at mx.core::Container/createComponentFromDescriptor()[E:\dev\4.0.0\frame works\projects\framework\src\mx\core\Container.as:4371]
        at mx.core::Container/createComponentsFromDescriptors()[E:\dev\4.0.0\fra meworks\projects\framework\src\mx\core\Container.as:4160]
        at mx.core::Container/createChildren()[E:\dev\4.0.0\frameworks\projects\ framework\src\mx\core\Container.as:3187]
        at mx.core::UIComponent/initialize()[E:\dev\4.0.0\frameworks\projects\fr amework\src\mx\core\UIComponent.as:7250]
        at mx.core::Container/initialize()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\core\Container.as:3129]
        at SequenceDetail/initialize()
        at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent. as:7142]
        at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Container.as :3951]
        at mx.core::Container/addChildAt()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\core\Container.as:2616]
        at mx.containers::ViewStack/addChildAt()[E:\dev\4.0.0\frameworks\project s\framework\src\mx\containers\ViewStack.as:1426]
        at com::MyDBResult/displaySequenceDetail()[/Users/jbhavsar/Documents/wor kspace/virome/src/com/MyDBResult.as:114]
        at <anonymous>()[/Users/jbhavsar/Documents/workspace/virome/src/com/MyDB Result.as:103]
        at flash.events::EventDispatcher/dispatchEventFunction()
        at flash.events::EventDispatcher/dispatchEvent()
        at ModuleInfoProxy/moduleEventHandler()[E:\dev\4.0.0\frameworks\projects \framework\src\mx\modules\ModuleManager.as:1168]
        at flash.events::EventDispatcher/dispatchEventFunction()
        at flash.events::EventDispatcher/dispatchEvent()
        at ModuleInfo/readyHandler()[E:\dev\4.0.0\frameworks\projects\framework\ src\mx\modules\ModuleManager.as:812]
        at flash.events::EventDispatcher/dispatchEventFunction()
        at flash.events::EventDispatcher/dispatchEvent()
        at mx.core::FlexModuleFactory/update()[E:\dev\4.0.0\frameworks\projects\ framework\src\mx\core\FlexModuleFactory.as:433]
        at mx.core::FlexModuleFactory/docFrameHandler()[E:\dev\4.0.0\frameworks\ projects\framework\src\mx\core\FlexModuleFactory.as:582]
        at mx.core::FlexModuleFactory/docFrameListener()[E:\dev\4.0.0\frameworks \projects\framework\src\mx\core\FlexModuleFactory.as:126]

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

     

    Thanks

    Jay

     

    p.s: Please dont hammer me if my code isn't upto standard, I am learning this as I go along.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 22, 2010 10:24 AM   in reply to kingquattro

    If SequenceDetail is the module class you are linking the module into the

    main app and that effectively defeats the point of modules and will cause

    errors in the style system.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 22, 2010 10:50 AM   in reply to Flex harUI

    Hi

         I agree that this does defeat the purpose of Module but we had developed it so that two portion of the app can be developed independently.  I think I am going to convert it into a panel component, and keep it hidden unless needed.

     

    Jay

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 22, 2010 2:13 PM   in reply to kingquattro

    You should use a common interface.   That's the recommended practice.  Once

    you do that, you'll see that the app gets smaller because it no longer links

    in the module class.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 3, 2013 6:02 AM   in reply to Flex harUI

    I was stuck on this protochain error for days!! I migrated from SDK3.5 to 4.6...

     

    I eventually found the solution - it is a bug in flex... kudos goes to CarbonRider http://flex.carbonrider.com/2010/11/17/flex-3-to-flex-4-migration/

     

    the actual problem is that stylesRoot is null for the module you are trying to load...

     

    so to fix it put this code in before calling addChild()

     

                        var child:DisplayObject = DisplayObject(module.factory.create());

                        var b:IStyleManager2 = StyleManager.getStyleManager(IFlexModule(child).moduleFactory); //(child) is instance of the module loaded

                        if (b.stylesRoot == null)

                        {

                                       b.stylesRoot = styleManager.stylesRoot;

                        }

      self = addChild(child);

     

     

    full code below....

     

              public var module:IModuleInfo;

              public var self:DisplayObject;

     

     

    private function init():void

              {

                        module = ModuleManager.getModule(swfURL);

                        module.addEventListener(ModuleEvent.READY, moduleReady);

                        module.load(ApplicationDomain.currentDomain,null,null,moduleFactory);

              }

              private function moduleReady(e:ModuleEvent):void

              {

                        var child:DisplayObject = DisplayObject(module.factory.create());

                        var b:IStyleManager2 = StyleManager.getStyleManager(IFlexModule(child).moduleFactory); //(child) is instance of the module loaded

                        if (b.stylesRoot == null)

                        {

                                  b.stylesRoot = styleManager.stylesRoot;

                        }

                        self = addChild(child);

                  progbox.visible = false;

              }

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points