Select to view content in your preferred language

Pass Search Parameters via URL

5574
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
RobertScheitlin__GISP
MVP Emeritus
Sandra,

   Can you attach your SearchWidget.mxml and the URL that you are using for this?
0 Kudos
SandraPanicucci
Deactivated User
URL of the website =   http://arcgis.sd.gov/server/denr/bmpviewer/index.html?BMPID=10572
BMPID being the attribute I wish to search on. Hope you can make sense of this mess. Thanks for looking.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Sandra,

  I guess I will need you MapManger.mxml also. Line 587 in your SearchWidget.mxml that the error references is telling me that the querybmpid function is not receiving the query parameter (10572)
0 Kudos
SandraPanicucci
Deactivated User
Eventually I want the 10572 to be a number fed in from a different website but for now I'll be happy to get it to work with just that one. Unless what I hope to be able to do doesn't sound like it will work with the direction I'm heading here.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Sandra,

   Here is your code fixed.

Just replace the MapLoadComplete function in your MapManger.mxml with this one.

//map load complete
   private function mapLoadComplete(event:MapEvent):void
   {
    SiteContainer.dispatchEvent(new AppEvent(AppEvent.LAYER_LOADED, false, false, null));
    try
    {
     if (ExternalInterface.available)
     {
      var result:URLVariables = new URLVariables();
      var urlSubstring:String = ExternalInterface.call("window.location.search.substring", 1);    
      if (urlSubstring && urlSubstring.length > 0)
      {
       result.decode(urlSubstring);
       // Parse URL
       var xParam:String;
       var xExt:String;
       if (result["BMPID"])
        xParam = result.BMPID;
       if (result["EXT"])
        xExt = result.EXT;
       
       if (!xParam = ""){
        var timer:Timer = new Timer(4000, 1);
        timer.addEventListener(TimerEvent.TIMER_COMPLETE, timerComplete);
        timer.start();
       }
       if (!xExt == ""){
              var extArray:Array = xExt.split(",");
        var extent:Extent = new Extent(Number(extArray[0]), Number(extArray[1]), Number(extArray[2]), Number(extArray[3]),map.spatialReference);
        map.extent = extent;
             }
       
       function timerComplete( event:TimerEvent ):void
       {
        timer.removeEventListener(TimerEvent.TIMER_COMPLETE, timerComplete);
        var id:Number = SiteContainer.getInstance().getWidgetId("Search");
        var bWidget:IBaseWidget = SiteContainer.getInstance().widgetManager.getWidget(id) as IBaseWidget;
        
        if (bWidget){
         var bWidg:BaseWidget = bWidget.getInstance();
         var vSW:SearchWidget = bWidg as SearchWidget;
         vSW.querybmpid(xParam);
        } else {
         var bWidget2:IBaseWidget;
         bWidget2 = SiteContainer.getInstance().widgetManager.getWidget(id) as IBaseWidget;
         var vSW2:SearchWidget = bWidget2 as SearchWidget;
         vSW2.querybmpid(xParam);
        }
       }
      }
     }
    }
    catch (error:Error){}
    refreshLayer("BMP Locations",30000);
    //uncomment if you are using my enhanced draw widget
    //map.addLayer(drawgLayer); 
   }
0 Kudos
SandraPanicucci
Deactivated User
Well it's a new error anyway.

Line 218      if (!xParam = ""){

produces this error when building

1050: Cannot assign to a non-reference value. MapManager.mxml FlexViewer/src/com/esri/solutions/flexviewer line 218 Flex Problem
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Sandra,

   Sorry that was suppose to be
CODE]if (!xParam == ""){
0 Kudos
SandraPanicucci
Deactivated User
Looking much better! Thank you... It is going to the Search Widget  but now I get the following errors.
***this in an error box on the site***

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.esri.solutions.flexviewer:MapManager/refreshLayer/com.esri.solutions.flexviewer:timerHandler()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()


***And this from the SearchWidget***

Error #1009: Cannot access a property or method of a null object reference.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Sandra,

   Ok this line is the culprit
refreshLayer("BMP Locations",30000);

so is "BMP Locations the exact map service id/Label that you have in your config.xml?
0 Kudos