LayerList Widget null object error

442
1
10-25-2013 10:44 AM
FrankRoberts
Occasional Contributor III
I have evoked the LayerList widget in one of my config files that has some services that a secured with a token embed in the config file.  The viewer and layers all load fine. However, when I select the LayerList widget I get the following error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.esri.viewer.components.toc.tocClasses::TocMapLayerItem/createChildren()
at com.esri.viewer.components.toc.tocClasses::TocMapLayerItem()
at com.esri.viewer.components.toc::TOC/registerMapLayer()
at MethodInfo-307()
at com.esri.viewer.components.toc.utils::MapUtil$/forEachMapLayer()
at com.esri.viewer.components.toc::TOC/registerAllMapLayers()
at com.esri.viewer.components.toc::TOC/commitProperties()
at mx.core::UIComponent/validateProperties()
at mx.managers::LayoutManager/validateProperties()
at mx.managers::LayoutManager/doPhasedInstantiation()
at mx.managers::LayoutManager/doPhasedInstantiationCallback()


Any idears?
Tags (2)
0 Kudos
1 Reply
GISDev1
Occasional Contributor III
Have you tracked it down to being a problem with the Secure services? Did everything work fine with the Secure services removed from the config file? If it did, maybe try leaving the Secured services turned on, but remove all of the pop-ups for the Secure services and see if you get the same error.

I'm not sure if my problem from a few months ago is the same as what you are experiencing, but it's worth a try. I was experiencing issues with the createChildren due to some kind of popup config related bug, and this is how I fixed it back then:


This is how I fixed this in the createChildren function in TocMapLayerItem.as found in Robert's TOC Widget v 3.3.0 (5/6/13) code here: /widgets/TOC/toc/tocClasses/TocMapLayerItem.as around line 912:

private function createChildren():void
     {
         children = null;
         var layerInfos:Array; // of LayerInfo
         var visibleLayers:Array;
   var li:LayerInfo;
         if (layer is ArcGISTiledMapServiceLayer){
             layerInfos = ArcGISTiledMapServiceLayer(layer).layerInfos;
  
         }else if (layer is ArcGISDynamicMapServiceLayer){
    var arcGISDynamicMapServiceLayer:ArcGISDynamicMapServiceLayer = ArcGISDynamicMapServiceLayer(layer);
    
    if (arcGISDynamicMapServiceLayer.visibleLayers == null) { //Added if check for bugfix
     trace("found null");
    }
    else {
     arcGISDynamicMapServiceLayer.visibleLayers.addEventListener(CollectionEvent.COLLECTION_CHANGE, visibleLayersChangeHandler);
    }
    
    _visibleLayersChangeWatcher = ChangeWatcher.watch(arcGISDynamicMapServiceLayer, "visibleLayers", visibleLayersChange);
    
    _dynamicMapServiceLayerInfos = arcGISDynamicMapServiceLayer.dynamicLayerInfos ? arcGISDynamicMapServiceLayer.dynamicLayerInfos : arcGISDynamicMapServiceLayer.layerInfos; //Added per commit on GH
         
    
    if (_isVisibleLayersSet){
....all code is the same for the rest of the createChildren function
     



As shown in this post in Robert's retired TOC thread:
http://forums.arcgis.com/threads/18453-Table-of-Contents-Legend-Widget-for-FlexViewer-2.x?p=312248&v...


If this doesn't fix it, can you post any further information on your error messages either in Flash Builder or the Flash Player Debug information popup? I notice that sometimes my Debug Flash Player Error Message is actually better at helping me track down the problem than the error message I get in Debug mode inside Flash Builder, although I have no idea why that happens.
0 Kudos