6 Replies Latest reply on Nov 25, 2007 2:41 AM by goingflex

    null object reference from HistoryManager

    steveh1234
      I get a lot of the error below. Am I doing something wrong, or is this potentially a bug? It happens sometimes when going between tabs or changing an accordian control from one canvas to another.

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at mx.managers::HistoryManager$/save()
      at mx.containers::ViewStack/::hideEffectEndHandler()
      at mx.containers::ViewStack/::commitSelectedIndex()
      at mx.containers::ViewStack/mx.containers:ViewStack::commitProperties()
      at mx.containers::TabNavigator/mx.containers:TabNavigator::commitProperties()
      at mx.core::UIComponent/validateProperties()
      at mx.managers::LayoutManager/::validateProperties()
      at mx.managers::LayoutManager/::doPhasedInstantiation()
      at mx.core::UIComponent/::callLaterDispatcher2()
      at mx.core::UIComponent/::callLaterDispatcher()

      Thanks,

      Steve
        • 1. Re: null object reference from HistoryManager
          Level 7
          It could be either one -- maybe a bug in Flex, or maybe a bug in your code.
          Could you use the Flex Builder debugger to tell me which line of
          HistoryManager.save() has the problem, and which variable is null? That would
          help us figure out if it's a Flex problem.

          --
          Mike Morearty
          Developer, Flex Builder team
          http://www.morearty.com/blog


          steveh1234 wrote:
          > I get a lot of the error below. Am I doing something wrong, or is this
          > potentially a bug? It happens sometimes when going between tabs or changing an
          > accordian control from one canvas to another.
          >
          > TypeError: Error #1009: Cannot access a property or method of a null object
          > reference.
          > at mx.managers::HistoryManager$/save()
          > at mx.containers::ViewStack/::hideEffectEndHandler()
          > at mx.containers::ViewStack/::commitSelectedIndex()
          > at mx.containers::ViewStack/mx.containers:ViewStack::commitProperties()
          > at mx.containers::TabNavigator/mx.containers:TabNavigator::commitProperties()
          > at mx.core::UIComponent/validateProperties()
          > at mx.managers::LayoutManager/::validateProperties()
          > at mx.managers::LayoutManager/::doPhasedInstantiation()
          > at mx.core::UIComponent/::callLaterDispatcher2()
          > at mx.core::UIComponent/::callLaterDispatcher()
          >
          > Thanks,
          >
          > Steve
          >
          • 2. Re: null object reference from HistoryManager
            samagination79
            getting the same error when I have an accordion that is any other state than the base state. Not sure if this is what you needed but looks like line 558

            TypeError: Error #1009: Cannot access a property or method of a null object reference.

            at mx.managers::HistoryManager$/save()[C:\dev\beta3\sdk\frameworks\mx\managers\HistoryManage r.as:558]
            • 3. Re: null object reference from HistoryManager
              samagination79 Level 1
              Posted this in another topic but here is a simple app to show the error in action

              <?xml version="1.0" encoding="utf-8"?>
              <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
              <mx:states>
              <mx:State name="home">
              <mx:RemoveChild target="{hbox1}"/>
              <mx:AddChild position="lastChild">
              <mx:HBox x="0" y="0" width="100%" height="100%">
              <mx:Panel width="250" height="100%" layout="absolute">
              <mx:Accordion x="0" y="0" width="100%" height="100%">
              <mx:VBox label="test1" width="100%" height="100%">
              </mx:VBox>
              <mx:VBox label="test2" width="100%" height="100%">
              </mx:VBox>
              </mx:Accordion>
              </mx:Panel>
              <mx:Panel width="100%" height="100%" layout="absolute">
              </mx:Panel>
              </mx:HBox>
              </mx:AddChild>
              </mx:State>
              </mx:states>

              <mx:HBox x="0" y="0" width="100%" height="100%" id="hbox1">
              <mx:Button label="Button" click="currentState='home';"/>
              </mx:HBox>
              </mx:Application>
              • 4. Re: null object reference from HistoryManager
                steveh1234 Level 1
                Yes mine seemed to be related to changing states as well. I redid everything completely using the design mode and it seems to work now. Odd.
                • 5. Re: null object reference from HistoryManager
                  Level 7
                  Hi samagination79,
                  > Posted this in another topic but here is a simple app to show the error in
                  > action

                  I can't reproduce the error in our latest internal build, so it's likely
                  this was a bug in beta 3 that was internally fixed since then.

                  Since the error seems related to the HistoryManager, if you need a
                  workaround in the meantime, you might try setting
                  historyManagementEnabled="false" on your Accordion to see if that avoids
                  the problem.

                  --
                  nj
                  Flex Builder team
                  • 6. Re: null object reference from HistoryManager
                    goingflex
                    I am in FB3 Beta 2 and have:

                    public function initApp() :void
                    {
                    HistoryManager.register(this);
                    addEventListener(StateChangeEvent.CURRENT_STATE_CHANGE,
                    handleStateChange);
                    initCollections();
                    }

                    /**
                    * Implementation of saveState() method required by
                    * the IHistoryManagerClient interface.
                    */
                    public function saveState() :Object
                    {
                    var historyState:Object = new Object();
                    historyState.currentState = currentState;
                    return historyState;
                    }

                    /**
                    * Implementation of loadState() method required by the
                    * IHistoryManagerClient interface.
                    */
                    public function loadState(historyState:Object) :void
                    {


                    // Temporarily ignore currentStateChange events.
                    removeEventListener(StateChangeEvent.CURRENT_STATE_CHANGE,
                    handleStateChange);

                    if (historyState == null)
                    { // TRICKY: Null value indicates that initial state is required.
                    currentState = "";
                    }
                    else
                    {
                    currentState = historyState.currentState;
                    }

                    // Listen for currentStateChange events again.
                    addEventListener(StateChangeEvent.CURRENT_STATE_CHANGE,
                    handleStateChange);
                    }

                    public function handleStateChange(event:StateChangeEvent) :void
                    {
                    HistoryManager.save();
                    }

                    I have an accoprdion on same state:
                    <mx:Accordion width="100%" height="90%" id="toppage_accordeon" historyManagementEnabled="false">

                    When I go back and forth in states I gwt an error message even with HistoryManager disabled for the accordion.

                    TypeError: Error #1009: Il est impossible d'accéder à la propriété ou à la méthode d'une référence d'objet nul.
                    at mx.managers::HistoryManagerImpl/browserURLChangeHandler()[E:\dev\flex_3_beta2\sdk\framewo rks\projects\framework\src\mx\managers\HistoryManagerImpl.as:644]
                    at flash.events::EventDispatcher/dispatchEventFunction()
                    at flash.events::EventDispatcher/dispatchEvent()
                    at mx.managers::BrowserManagerImpl/browserURLChange()[E:\dev\flex_3_beta2\sdk\frameworks\pro jects\framework\src\mx\managers\BrowserManagerImpl.as:347]
                    at mx.managers::BrowserManagerImpl/browserURLChangeBrowser()[E:\dev\flex_3_beta2\sdk\framewo rks\projects\framework\src\mx\managers\BrowserManagerImpl.as:333]
                    at Function/ http://adobe.com/AS3/2006/builtin::apply()
                    at <anonymous>()
                    at flash.external::ExternalInterface$/_callIn()
                    at <anonymous>()

                    What is the issue according to you?
                    Thx.