Select to view content in your preferred language

Layer not refreshing after 2nd update (flex 2.1 ags 9.3.1)

610
2
12-22-2010 06:16 AM
grahamcooke
Regular Contributor
I have created a widget to change and view the statuses of barriers in a training area. I have a querytask that queries an mxd published as a service. My widget has a series of listboxes, the user drags barriers names from the first list into one of three different listboxes to represent the barrier statuses (day, night, varying times). Then they click update and a .net webservice performs an update on the sde database to change the statuses. i then run my querytask and display all the barriers on my map. the barriers are symbolised according to status using a uniquevaluerenderer.

This all works brilliantly the first time I do it. however, if i then decide that i have set a few barriers to the wrong status and do another change, the barriers shown on the map do not change. The webservice is still updating correctly because the values in the database are correct.

I am clearly missing something obvious. i have tried clearing the barriers layer before i run the query to display the barriers with their new statuses but it isn't working. Does anyone have any suggestions please?
Tags (2)
0 Kudos
2 Replies
grahamcooke
Regular Contributor
Here's an extract of the relevant code if it helps!

private function updateBarriers():void
{var listItems:ArrayCollection = new ArrayCollection(); 
//update the statuses as per the lists
if (lstDay.dataProvider.length > 0)
{listItems.source = lstDay.dataProvider.toArray();
updateBarrierStatuses("Day", listItems);}
if (lstNight.dataProvider.length > 0)
{listItems.source = lstNight.dataProvider.toArray();
updateBarrierStatuses("Night", listItems); }
if (lstVarying.dataProvider.length > 0)
{listItems.source = lstVarying.dataProvider.toArray();
updateBarrierStatuses("Varying", listItems);}
if (lstBarrierNames.dataProvider.length > 0)
{listItems.source = lstBarrierNames.dataProvider.toArray();
updateBarrierStatuses("Not Set", listItems);}
doShowAllBarriersQuery();
listItems = null;
}
private function updateBarrierStatuses(barrierType:String, items:ArrayCollection):void
{//create a variable to store the barrier name strings
var barrierNames:String = "";
var i:Number = 0;
//for the time being we are only working with 4 statuses. This means there is no need to determine id's at runtime
//if we need to implement different barrier statuses for different training areas and these need to be retrieved at run
//time then this will need to change!
var barrierStatus:Number;
switch (barrierType)
{case "Day":
{for(i = 0; i < items.length; i++)
{barrierNames = barrierNames + items.toString() + ",";
barrierStatus = 1;} 
break;
}
case "Night":{
for(i = 0; i < items.length; i++)
{ barrierNames = barrierNames + items.toString() + ",";
barrierStatus = 2;} 
break;}
case "Varying":{
for(i = 0; i < items.length; i++)
{ barrierNames = barrierNames + items.toString() + ",";
barrierStatus = 3;} 
break;}
case "Not Set":{
for(i = 0; i < items.length; i++)
{ barrierNames = barrierNames + items.toString() + ",";
barrierStatus = 4;} 
break;}
} //end switch
//remove the last "," from the list
barrierNames = barrierNames.substr(0, barrierNames.length - 1);
setBarrierStatusesWS(myTrainingAreaName, barrierNames, barrierStatus);}
private function setBarrierStatusesWS(trainingArea:String, barrierNames:String, status:Number):void
{myWS.updateBarrierStatus(trainingArea, barrierNames, status);}
private function doShowAllBarriersQuery() : void
{//empty the barrier layer first.
gfxBarriers.clear();
//set up a unique renderer to symbolise the barrier layer
// ref:http://resources.esri.com/help/9.3/arcgisserver/apis/flex/help/index.html#renderers.htm#
var uniqueValuerenderer:UniqueValueRenderer = new UniqueValueRenderer();
uniqueValuerenderer.attribute = "cawdapt_dev.CAWDAPT.Barriers.BARRIER_STATUS_ID";
var uniqueValueInfos:Array =[];
uniqueValueInfos.push(new UniqueValueInfo(daySymbol, "1"));
uniqueValueInfos.push(new UniqueValueInfo(nightSymbol, "2"));
uniqueValueInfos.push(new UniqueValueInfo(varySymbol, "3"));
uniqueValuerenderer.infos = uniqueValueInfos;
gfxBarriers.renderer = uniqueValuerenderer;
allBarriersQuery.where = " cawdapt_dev.CAWDAPT.Barriers.BARRIER_STATUS_ID <> 4";
queryTask.execute( allBarriersQuery, new AsyncResponder(onResult, onFault ));
function onGetBarrierResult( featureSet:FeatureSet, token : Object = null ) : void
{var displayFieldName : String = featureSet.displayFieldName;
for each ( var myGraphic : Graphic in featureSet.features )
{myGraphic.toolTip = "Barrier: " + myGraphic.attributes["cawdapt_dev.CAWDAPT.Barriers.BARRIER_NAME"] + "." ;
gfxBarriers.add( myGraphic );}
//zoom to full extent of map:
var graphicProvider:ArrayCollection = gfxBarriers.graphicProvider as ArrayCollection;
var graphicsExtent:Extent = GraphicUtil.getGraphicsExtent(graphicProvider.toArray());}
function onGetBarrierFault( info : Object, token : Object = null ) : void
{Alert.show( info.toString() );}
}
<!--Web service results handling:--> 
<esri:QueryTask id="queryTask" url="http://lmgis02/ArcGIS/rest/services/Barriers/MapServer/0" useAMF="false"/>
<esri:Query id="allBarriersQuery" returnGeometry="true">
<esri:outFields>
<fx:String>CAWDAPT_DEV.CAWDAPT.BARRIERS.BARRIER_NAME</fx:String>
<fx:String>CAWDAPT_DEV.CAWDAPT.BARRIERS.BARRIER_STATUS_ID</fx:String>
<fx:String>CAWDAPT_DEV.CAWDAPT.BARRIER_STATUSES.BARRIER_SYMBOL</fx:String>
<fx:String>CAWDAPT_DEV.CAWDAPT.BARRIER_STATUSES.SYMBOL_COLOUR</fx:String>
</esri:outFields>
</esri:Query>
<mx:TabNavigator width="100%" height="95%" x="0" y="0">
<mx:Canvas label="Set Barriers" width="100%" height="100%" backgroundColor="#D8D8D8">
<s:VGroup>
<mx:HRule width="100%" height="3"/>
<s:HGroup id="BarriersGroup">
<s:VGroup>
<s:Label id="lblName" text="Barrier Name" toolTip="You can select multiple items by holding CTRL key and clicking, or select a block by holding shift key and clicking"/> 
<s:List id="lstBarrierNames" dragEnabled="true" dropEnabled="false" allowMultipleSelection="true" dragMoveEnabled="true" dataProvider="{barrierNameArray}" styleName="ListControl" skinClass="Landmarc.customSkins.BarrierListSkin" />
</s:VGroup>
<s:VGroup>
<s:Label id="lblDay" text="Day" toolTip="Drag and Drop Barriers open during the day into this column"/>
<s:List id="lstDay" dragEnabled="true" dropEnabled="true" allowMultipleSelection="true" dragMoveEnabled="true" dataProvider="{new ArrayCollection([])}" styleName="ListControl" skinClass="Landmarc.customSkins.BarrierListSkin"/>
</s:VGroup>
<s:VGroup>
<s:Label id="lblNight" text="Night" toolTip="Drag and Drop Barriers open at night into this column"/>
<s:List id="lstNight" dragEnabled="true" dropEnabled="true" allowMultipleSelection="true" dragMoveEnabled="true" dataProvider="{new ArrayCollection([])}" styleName="ListControl" skinClass="Landmarc.customSkins.BarrierListSkin" />
</s:VGroup>
<s:VGroup>
<s:Label id="lblVary" text="Varying" toolTip="Drag and Drop Barriers open at varying times into this column"/>
<s:List id="lstVarying" dragEnabled="true" dropEnabled="true" allowMultipleSelection="true" dragMoveEnabled="true" dataProvider="{new ArrayCollection([])}" styleName="ListControl" skinClass="Landmarc.customSkins.BarrierListSkin"/>
</s:VGroup>
</s:HGroup>
<mx:HRule width="100%" height="3"/>
<s:Button label="Save barriers statuses" click="updateBarriers()"/>
</s:VGroup>
</mx:Canvas>
0 Kudos
grahamcooke
Regular Contributor
Fixed this....knew it would be simple :mad:

For anyone who has the same issue, all you have to do is set disableclientcaching =true on the querytask!
0 Kudos