11 Replies Latest reply: Apr 3, 2013 6:02 AM by Gallopaway75 RSS

    Flex 4 - Error with DataGrid in Module

    Chris_Hof

      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\framewor ks\projects\framework\src\mx\styles\StyleProtoChain.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!

        • 1. Re: Flex 4 - Error with DataGrid in Module
          Darrell Loverin Adobe Employee

          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

          • 2. Re: Flex 4 - Error with DataGrid in Module
            Chris_Hof Community Member

            The module is loaded into an <mx:ModuleLoader> by changing it's url parameter. There are a few other modules in the application that work fine, and this one used to work fine before making the switch to Flex 4 final. Maybe I've hit a bug?

            • 3. Re: Flex 4 - Error with DataGrid in Module
              kubens Community Member

              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.

              • 4. Re: Flex 4 - Error with DataGrid in Module
                Flex harUI Adobe Employee

                What error are you getting?

                • 5. Re: Flex 4 - Error with DataGrid in Module
                  Chris_Hof Community Member

                  The full error:

                   

                  TypeError: Error #1009: Der Zugriff auf eine Eigenschaft oder eine Methode eines null-Objektverweises ist nicht möglich.
                       at mx.styles::StyleProtoChain$/initProtoChainForUIComponentStyleName()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\styles\StyleProtoChain.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\projects\framework\src\mx\core\UIComponent.as:10249]
                       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::UIComponent/addChild()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:6811]
                       at mx.controls.listClasses::ListBase/createChildren()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\controls\listClasses\ListBase.as:3774]
                       at mx.controls::DataGrid/createChildren()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\controls\DataGrid.as:1133]
                       at mx.core::UIComponent/initialize()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:7250]
                       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\framework\src\mx\core\Container.as:2616]
                       at mx.core::Container/addChild()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Container.as:2534]
                       at mx.core::Container/createComponentFromDescriptor()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Container.as:4371]
                       at mx.core::Container/createComponentsFromDescriptors()[E:\dev\4.0.0\frameworks\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\framework\src\mx\core\UIComponent.as:7250]
                       at mx.core::Container/initialize()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Container.as:3129]
                       at modules::Benutzerverwaltung/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\framework\src\mx\core\Container.as:2616]
                       at mx.core::Container/addChild()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Container.as:2534]
                       at mx.modules::ModuleLoader/moduleReadyHandler()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\modules\ModuleLoader.as:468]
                       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]
                  
                  • 6. Re: Flex 4 - Error with DataGrid in Module
                    Darrell Loverin Adobe Employee

                    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

                    • 7. Re: Flex 4 - Error with DataGrid in Module
                      kingquattro

                      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\framewor ks\projects\framework\src\mx\styles\StyleProtoChain.as:356]
                          at mx.styles::StyleProtoChain$/initProtoChain()[E:\dev\4.0.0\frameworks\projects\framework\s rc\mx\styles\StyleProtoChain.as:171]
                          at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::initProtoChain()[E:\dev\4.0.0\frameworks\proje cts\framework\src\mx\core\UIComponent.as:10186]
                          at mx.core::UIComponent/regenerateStyleCache()[E:\dev\4.0.0\frameworks\projects\framework\sr c\mx\core\UIComponent.as:10249]
                          at mx.core::Container/regenerateStyleCache()[E:\dev\4.0.0\frameworks\projects\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\s rc\mx\core\ContainerRawChildrenList.as:143]
                          at mx.containers::TabNavigator/createChildren()[E:\dev\4.0.0\frameworks\projects\framework\s rc\mx\containers\TabNavigator.as:559]
                          at mx.core::UIComponent/initialize()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\ UIComponent.as:7250]
                          at mx.core::Container/initialize()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Co ntainer.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\framework\src\mx\core\Co ntainer.as:2616]
                          at mx.core::Container/addChild()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Cont ainer.as:2534]
                          at mx.core::Container/createComponentFromDescriptor()[E:\dev\4.0.0\frameworks\projects\frame work\src\mx\core\Container.as:4371]
                          at mx.core::Container/createComponentsFromDescriptors()[E:\dev\4.0.0\frameworks\projects\fra mework\src\mx\core\Container.as:4160]
                          at mx.containers::Panel/createComponentsFromDescriptors()[E:\dev\4.0.0\frameworks\projects\f ramework\src\mx\containers\Panel.as:1685]
                          at mx.core::Container/createChildren()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\cor e\Container.as:3187]
                          at mx.containers::Panel/createChildren()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\c ontainers\Panel.as:1198]
                          at mx.core::UIComponent/initialize()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\ UIComponent.as:7250]
                          at mx.core::Container/initialize()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Co ntainer.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\framework\src\mx\core\Co ntainer.as:2616]
                          at mx.core::Container/addChild()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Cont ainer.as:2534]
                          at mx.core::Container/createComponentFromDescriptor()[E:\dev\4.0.0\frameworks\projects\frame work\src\mx\core\Container.as:4371]
                          at mx.core::Container/createComponentsFromDescriptors()[E:\dev\4.0.0\frameworks\projects\fra mework\src\mx\core\Container.as:4160]
                          at mx.core::Container/createChildren()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\cor e\Container.as:3187]
                          at mx.core::UIComponent/initialize()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\ UIComponent.as:7250]
                          at mx.core::Container/initialize()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Co ntainer.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\framework\src\mx\core\Co ntainer.as:2616]
                          at mx.containers::ViewStack/addChildAt()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\c ontainers\ViewStack.as:1426]
                          at com::MyDBResult/displaySequenceDetail()[/Users/jbhavsar/Documents/workspace/virome/src/co m/MyDBResult.as:114]
                          at <anonymous>()[/Users/jbhavsar/Documents/workspace/virome/src/com/MyDBResult.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\mo dules\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\Modul eManager.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\cor e\FlexModuleFactory.as:433]
                          at mx.core::FlexModuleFactory/docFrameHandler()[E:\dev\4.0.0\frameworks\projects\framework\s rc\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.

                      • 8. Re: Flex 4 - Error with DataGrid in Module
                        Flex harUI Adobe Employee

                        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.

                        • 9. Re: Flex 4 - Error with DataGrid in Module
                          kingquattro Community Member

                          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

                          • 10. Re: Flex 4 - Error with DataGrid in Module
                            Flex harUI Adobe Employee

                            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.

                            • 11. Re: Flex 4 - Error with DataGrid in Module
                              Gallopaway75

                              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;

                                        }