Select to view content in your preferred language

query a feature layer and the onfault function is being called

665
2
09-14-2011 05:45 AM
PeterHoffman
Deactivated User
I am trying to query a feature layer and the onfault function is being called. The first query works fine but the second one - // Status part does not.

Any ideas?

Thanks.



<?xml version="1.0" encoding="utf-8"?>
<!--
     ////////////////////////////////////////////////////////////////////////////////
     //
     // Copyright (c) 2010 ESRI
     //
     // All rights reserved under the copyright laws of the United States.
     // You may freely redistribute and use this software, with or
     // without modification, provided you include the original copyright
     // and use restrictions.  See use restrictions in the file:
     // <install location>/License.txt
     //
     ////////////////////////////////////////////////////////////////////////////////
-->
<viewer:BaseWidget xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx"
                   xmlns:viewer="com.esri.viewer.*"
                   widgetConfigLoaded="init()">
    <fx:Script>
        <![CDATA[
   import com.esri.ags.FeatureSet;
   import com.esri.ags.layers.FeatureLayer;
   import com.esri.ags.tasks.supportClasses.Query;
   import com.esri.viewer.components.HTMLPopup;
  
   import flashx.textLayout.edit.SelectionFormat;
   import flashx.textLayout.events.SelectionEvent;
  
   import mx.collections.ArrayCollection;
   import mx.collections.SortField;
   import mx.controls.Alert;
   import mx.rpc.AsyncResponder;
   import mx.rpc.events.FaultEvent;

            private var content:String;
   private var contentStatus:String;
            private var btnLabel:String
            private var txtareaWidth:Number;
            private var txtareaHeight:Number;
   private var sSheltersClosedMessage:String;
   private var sSheltersOpenMessage:String;
  
  
   private var fLayer:FeatureLayer
   private var statusLayer:FeatureLayer
  
            private function init():void
            {
                if (configXML)
                {
                    content = configXML.content || "...";
                    btnLabel = configXML.btnlabel || getDefaultString("okLabel");
                    txtareaWidth = configXML.width || 500;
                    txtareaHeight = configXML.height || 500;
     sSheltersClosedMessage = configXML.sheltersclosedmessage;
     sSheltersOpenMessage = configXML.sheltersopenmessage;
    
     fLayer = new FeatureLayer(configXML.sheltersurl);
     fLayer.useAMF = false;
    
     var qry:Query = new Query();
     qry.where = "OPEN = 1";
     // fLayer.queryFeatures(qry, new AsyncResponder(onResult, onFault));
    
     // Status part
     statusLayer = new FeatureLayer("http://gis.co.suffolk.ny.us/ArcGIS/rest/services/EmergencyShelters/MapServer/1");  
     fLayer.useAMF = false;
    
     var qryStatus:Query = new Query();
     qryStatus.where = "STATUS = 1";
     statusLayer.queryFeatures(qryStatus, new AsyncResponder(onResultStatus, onFault));   
    
                }
       
    function onResultStatus(fSet:FeatureSet, token:Object=null):void
    {
     trace("Result");
     if(fSet.features.length > 0)
     {
      contentStatus = "HERE1";
     
      HTMLPopup.show(contentStatus, btnLabel, txtareaWidth, txtareaHeight);
     }
     else
     {
      contentStatus = "HERE";
      HTMLPopup.show(contentStatus, btnLabel, txtareaWidth, txtareaHeight);
     
     }
    }
       
    function onResult(fSet:FeatureSet, token:Object=null):void
    {
     trace("Result");
    
     if(fSet.features.length > 0)
     {
      content = content.replace("[SHELTERMESSAGETOKEN]", sSheltersOpenMessage);
     
     
      var arr:Array = new Array();
      for(var i:int=0; i<fSet.features.length; i++)
      {
       arr.push(fSet.attributes.NAME);
      }
      arr.sort();
     
     
      var tmp:String = "";
      for(i=0; i<arr.length; i++)
      {
       tmp += arr + "<br>";
      }
      tmp = tmp += "<br>";
     
     
      content = content.replace("[OPENSHELTERSTOKEN]", tmp);
      var bkgrndColor:String = "0x00FF00";
      HTMLPopup.show(content, btnLabel, txtareaWidth, txtareaHeight);
     }
     else
     {
      content = content.replace("[SHELTERMESSAGETOKEN]", sSheltersClosedMessage);
      HTMLPopup.show(content, btnLabel, txtareaWidth, txtareaHeight);
    
     }
    }
   
    function onFault(info:Object, token:Object = null):void
    {
     trace("Fault");
    }
            }
        ]]>
    </fx:Script>
</viewer:BaseWidget>
Tags (2)
0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus
Peter,

   As this is a Flex Viewer/Widget Question you need to re-post it to the Flex Viewer forum and I will answer it there:

http://forums.arcgis.com/forums/111-ArcGIS-Viewer-for-Flex
0 Kudos
PeterHoffman
Deactivated User
0 Kudos