Select to view content in your preferred language

Pass URL parameters in sample viewer

7756
49
11-03-2010 08:08 AM
AaronNash
Deactivated User
There was a previous thread on the old forum to pass search parameters into a url string,
http://forums.esri.com/Thread.asp?c=158&f=2421&t=294907&mc=104#msgid925229
I would like to see if anyone has accomplished this for the new viewer. I have a non-spatial flex application that runs a query on a ArcServer service and returns the results into a datagrid, I then have a button that exports the results into a pdf report. I would like to have another function that takes a value from the datagrid, populates it into a URL string that opens a new browser and zooms to that selected feature. 

thanks,
  Aaron
Tags (2)
0 Kudos
49 Replies
AaronNash
Deactivated User
I put the break point there
public function queryPPIN(xPPIN:String):void
at that point the xPPIN is still populated with the correct text, once you step forward it jumps straight to
function onFault(info:Object, token:Object = null):void
xPPIN is still populated with the correct text, but most of the other fields are null
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Aaron,

  Try changing this line in the queryPPIN function from:

var i:Number = cboLayerText.selectedIndex;


to

var i:Number = 0;
0 Kudos
AaronNash
Deactivated User
I was able get the query to run, I changed the parameters
    var i:Number = 0;
    queryLayer = "http://gis.vernon-ct.gov/ArcGISweb/rest/services/Flex_Vernon/MapServer/10";
    queryExpr = "Parcels.DBO.Parcels.MBL LIKE '[value]%'";
    queryFields = configSearchText.fields;
    queryTitleField = "PARCEL ID";


now it executes the search. When i try to hardcode the queryFields' values I get error 1067: Implicit coercion of a value of type String to an unrelated type XMLList. If I leave the values you provided configSearchText.fields, it does not query. If i remove the, it works.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Aaron,

   If you want to hardcode the fields than replace the whole function with this one.

public function queryPPIN(sPPIN:String):void
   {
    //hide infowindow if any
    map.infoWindow.hide();
    
    queryLayer = "http://gis.vernon-ct.gov/ArcGISweb/rest/services/Flex_Vernon/MapServer/10";
    queryExpr = "Parcels.DBO.Parcels.MBL LIKE '[value]%'";
    queryTitleField = "PARCEL ID";
    queryLinkField = "";
    
    var queryTask:QueryTask = new QueryTask(queryLayer);
    if (configSearchText.useproxy && configData.proxyUrl)
    {
     queryTask.proxyURL = configData.proxyUrl;
    }
    var query:Query = new Query();
    var pExpr:String = sPPIN.toUpperCase();
    var expr:String = queryExpr.replace("[value]", pExpr);
    
    query.where = expr;
    var strFlds:String = "field1,field2,field3";
    var flds:Array = strFlds.split(",");
    query.outFields = flds;
    query.returnGeometry = true;
    query.outSpatialReference = map.spatialReference;
    queryTask.useAMF = false; // TODO: remove when a better solution (for checking 9.3 vs 10 AGS) is ready
    queryTask.execute(query, new AsyncResponder(onResult, onFault, queryFields));
    showMessage(loadingLabel, true);
    showStateResults();
    
    // on result
    function onResult(featureSet:FeatureSet, token:XMLList = null):void
    {
     try
     {
      searchResultAC = createSearchResults(featureSet, token);
      
      // share data
      addSharedData(widgetTitle, searchResultAC);
      showMessage(selectionLabel + " " + featureSet.features.length, false);
     }
     catch (error:Error)
     {
      showMessage(error.message, false);
     }
    }
    
    //on fault
    function onFault(info:Object, token:Object = null):void
    {
     showMessage(info.toString(), false);
    }
   }


And update this line with your real field names

var strFlds:String = "field1,field2,field3";
0 Kudos
MarkSmith1
Deactivated User
Hi Robert,

Any chance this is more straight forward in the 2.2 viewer? If not, is it possible to make this work with your enhanced search widget? Is there a way to bypass the search widget and just have the viewer execute the search if it finds URL parameters?

Thanks in advance for any advice.

Mark
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Mark,

   Nope. No easier. Yes it can be added to the eSearch just more work. You could by pass the widget but what are you ultimately after? If you only want to zoom the map to the correct location and have a graphic on the screen that you can do little to nothing with, than the answer is yes you can bypass the widget. Ultimately it is worth the effort of having this integrated into your search/eSearch widget the right way, even know it is initially a pain.
0 Kudos
SandraPanicucci
Deactivated User
I'm back again...Robert successfully talked me through this in the 1.3 library. I'm attempting to update to 2.x and my first problem comes when trying to load the SearchWidget I get an error #2036 Load Never Completed URL: file:///C:/inetpub/wwwroot/Copy%20of%20FlexViewer/bin-debug/ I've been through the forums and nothing seems to get rid of this error.
0 Kudos
JonFisher
Emerging Contributor
For those looking how to modify the sample viewer 2.2 to support passing the bounding coordinates in the URL, Robert Scheitlin has posted code to accomplish this here:
http://forums.arcgis.com/threads/21180-Passing-Parameter-to-Flex-Viewer
0 Kudos
SandraPanicucci
Deactivated User
I have been through the threads. I have changed the code according to URLSearch.txt  in this thread and searched through a couple of other threads. The search finctionality works fine to locate my BMPID and zoom to it however when I try to pass the BMPID into the search function via the URL I'm getting the following error message. Any ideas or suggestions on what I may need to change?



http://testgis.sd.gov/server/denr/bmpEdit1/index.html?BMPID=12

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.esri.viewer::ViewerContainer/getWidgetId()
at MethodInfo-223()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.utils::Timer/tick()
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Sandra,

   So do you have a getWidgetId function in your ViewerContainer.mxml file? In the 2.2.10 version of my Enhanced Search Widget I have a PDF that outlines all the needed code changes to the viewer to get this to work for the eSearch widget.

http://www.arcgis.com/home/item.html?id=5d4995ccdb99429185dfd8d8fb2a513e
0 Kudos