Select to view content in your preferred language

Pass Search Parameters via URL

5605
30
06-23-2010 08:40 AM
SandraPanicucci
Deactivated User
I've been trying to work my way through the http://forums.esri.com/Thread.asp?c=158&f=2421&t=294907&mc=104 thread but am still getting the following error.  I've been through this thread numerous times and don't seem to be able to see my problem. I'm fairly new at Flex and would greatly appreciate any help or suggestions.


TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.esri.solutions.flexviewer.widgets::SearchWidget/querybmpid()
at com.esri.solutions.flexviewer:MapManager/private:mapLoadComplete/com.esri.solutions.flexviewer:timerComplete()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.utils::Timer/tick()
Tags (2)
0 Kudos
30 Replies
SandraPanicucci
Deactivated User
This is the line from my config.XML ---  "BMP Locations" is the layer name in the map which contains the BMPID attribute.  

<mapservice label="BMP" type="dynamic" visible="true" alpha="1" icon="com/esri/solutions/flexviewer/assets/images/icons/i_flag.png">http://arcgis.sd.gov/ArcGIS/rest/services/BMP2/MapServer</mapservice>>

I tried changing this to simply "BMP" which is what it sounded like you were saying it should be...the map service id/Label... got rid of the mapmanager.mxml error that popped up on the site but still leaves me with
***Error #1009: Cannot access a property or method of a null object reference***
on the SearchWidget

I guess that means I'm one step closer. I believe my problem now lies in this ---

public function querybmpid(sParam:String):void
   {
   
    var i:Number = cboLayerText.selectedIndex;
    queryLayer = "http://arcgis.sd.gov/Arcgis/rest/services/BMP2/MapServer/0";
    queryExpr = "BMPID = '[value]'";
    queryFields = "BMPID";
    queryTitleField = "BMPID";


Section of the SearchWidget but many changes later I guess I still need help.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Sandra,

   Try this

public function querybmpid(sParam:String):void
   {
    
    var i:Number = cboLayerText.selectedIndex;
    queryLayer = "http://arcgis.sd.gov/Arcgis/rest/services/BMP2/MapServer/0";
    queryExpr = "BMPID = '[value]'";
    queryFields = "*";
    queryTitleField = "BMPID";
    queryLinkField = "";
0 Kudos
SandraPanicucci
Deactivated User
Thank You very very much! It worked.
0 Kudos
NatashaManzuiga
Regular Contributor
Thank You very very much! It worked.


Sandra, can u send me your sitecontainer...there is something that doesnt work on mine..Im trying to do the same thing u did...

Thanks

Naty
0 Kudos
SandraPanicucci
Deactivated User
Natasha, I've attached my sitecontainer. Hope it helps, if not, hopefully Robert will respond. He's the best.
0 Kudos
NatashaManzuiga
Regular Contributor
Natasha, I've attached my sitecontainer. Hope it helps, if not, hopefully Robert will respond. He's the best.


Oh....so fast!! :))))Thank u...

Naty
0 Kudos
NatashaManzuiga
Regular Contributor
Natasha, I've attached my sitecontainer. Hope it helps, if not, hopefully Robert will respond. He's the best.


This is my code in mapmanager.mxml...in attachment the code and the error...
0 Kudos
NatashaManzuiga
Regular Contributor
This is my code in mapmanager.mxml...in attachment the code and the error...


I see that I dont have this function getWidget(id) in widget manager  😞
SiteContainer.getInstance().widgetManager.getWidget(id)
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Natasha,

   Yep you missed a couple of steps from the older thread.

//Add to the BaseWidget.as

  /**
   * Added by me
   * so that I could get the widget instance
   */
  public function getInstance():BaseWidget
  {
   return _Widget;  
  }

//Add to the IBaseWidget.as

  /**
   * Used to get a refference to this widget for code
   */
  function getInstance():BaseWidget;

//Add to the WidgetManagerDocked.mxml

      public function getWidget(id:Number):IBaseWidget
      {
       var widget:IBaseWidget;
       var label:String = configData.configWidgets[id].label;
       var icon:String = configData.configWidgets[id].icon;
       var config:String = configData.configWidgets[id].config;
       var url:String = configData.configWidgets[id].url;
       if (widgetTable.containsKey(id))
       {
        widget = widgetTable.find(id) as IBaseWidget;
        widget.setState("maximized");
        var wObj:DisplayObject = widget as DisplayObject;
        scrollToWidget(wObj);
       }
       else
       {
        //module loaded
        if (moduleTable.containsKey(url))
        {
         var modInfo:IModuleInfo = moduleTable.find(url) as IModuleInfo;
         widget = modInfo.factory.create() as IBaseWidget;
         widget.setId(id);
         widget.setTitle(label);
         widget.setIcon(icon);
         widget.setConfig(config);
         widget.setConfigData(configData);
         widget.setMap(map);
         var widgetDO:DisplayObject = widget as DisplayObject;
      widgetBox.addChild(widgetDO);
         widgetTable.add(id, widget);
        }
        else
        {
         return null;
         loadWidget(id, url);
        }
       }
       return widget;
      }
0 Kudos
NatashaManzuiga
Regular Contributor
Natasha,

   Yep you missed a couple of steps from the older thread.

//Add to the BaseWidget.as

  /**
   * Added by me
   * so that I could get the widget instance
   */
  public function getInstance():BaseWidget
  {
   return _Widget;  
  }

//Add to the IBaseWidget.as

  /**
   * Used to get a refference to this widget for code
   */
  function getInstance():BaseWidget;

//Add to the WidgetManagerDocked.mxml

      public function getWidget(id:Number):IBaseWidget
      {
       var widget:IBaseWidget;
       var label:String = configData.configWidgets[id].label;
       var icon:String = configData.configWidgets[id].icon;
       var config:String = configData.configWidgets[id].config;
       var url:String = configData.configWidgets[id].url;
       if (widgetTable.containsKey(id))
       {
        widget = widgetTable.find(id) as IBaseWidget;
        widget.setState("maximized");
        var wObj:DisplayObject = widget as DisplayObject;
        scrollToWidget(wObj);
       }
       else
       {
        //module loaded
        if (moduleTable.containsKey(url))
        {
         var modInfo:IModuleInfo = moduleTable.find(url) as IModuleInfo;
         widget = modInfo.factory.create() as IBaseWidget;
         widget.setId(id);
         widget.setTitle(label);
         widget.setIcon(icon);
         widget.setConfig(config);
         widget.setConfigData(configData);
         widget.setMap(map);
         var widgetDO:DisplayObject = widget as DisplayObject;
      widgetBox.addChild(widgetDO);
         widgetTable.add(id, widget);
        }
        else
        {
         return null;
         loadWidget(id, url);
        }
       }
       return widget;
      }


Thank u Robert, I will try with it...

Naty
0 Kudos