Select to view content in your preferred language

ArcGIS FLEX API 2.2- How to load widget data every 30 second

4204
6
09-15-2014 03:12 AM
AnjithaSenarath
Deactivated User

I need to implement a widget with auto data load and refresh every 30 second. My environment as below

1) Flex API : ArcGIS Flex viewer 2.2 (cannot change  the version as many dependencies )

2) ArcGIS Server 10.1 SP1

I need to load widget data every 30 second after opening the widget. My widget container contains list of incident point and it need to be update 30 second or 1 min. How can I implement self loading widget ?

you advice is highly appreciate 

0 Kudos
6 Replies
AnthonyGiles
Honored Contributor


Anjitha,

Where is your data coming from? If it is being served from your arcgis server then you could add the layer as normal and use the autorefresh property of the layer:

http://resources.arcgis.com/en/help/flex-viewer/concepts/index.html#/Layer_tag_overview/01m30000000p...

If you are loading data from somewhere else (like a xml file) then have a look at how the GeoRSS feed handles the autorefresh:

https://github.com/Esri/arcgis-viewer-flex/blob/develop/src/widgets/GeoRSS/GeoRSSWidget.mxml

0 Kudos
AnjithaSenarath
Deactivated User

Thank you Anthony

Yes I am using ArcGIs server 10.1 and data coming from Map service.

I am using ArcGIS Flex viewer 2.2 and I couldn't get this auto refresh working even if I added auto-refresh property set to 30 . There was no call back to server and layer stay as It is .

Then I tried same setup with Feature service and It didn't work too. What I am missing here ? appreciate your direction

0 Kudos
BjornSvensson
Esri Regular Contributor

The refresh property didn't exist in the 2.2 version. It was added at 3.1 for FeatureLayer in FlexViewer.

http://resources.arcgis.com/en/help/flex-viewer/concepts/index.html#/What_was_new_in_ArcGIS_Viewer_3...

0 Kudos
AnjithaSenarath
Deactivated User

Bjorn Thank you for the reply

Actually It does even if ESRI is not  putting it on help pages

Here is steps to proceed if you use older version of Flex API.

1) Publish your map service (Map Service. No need feature service but layer type is feature)

2) In Flex viewer source code's go to > com.esri.viewers > Managers > MapManager.mxml and locate below function

private function addLayerToMap(layerObject:Object, operationalLayer:Boolean):void{}

In that find the switch and find the "   case "feature":  "  and add below code (which is not in original code)

if (autoRefresh > 0)

  {

  setInterval(featureLayer.refresh, autoRefresh * 1000);

  }

3) Go to layer config file and add autorefresh property as to layer xml file

autorefresh world is case sensitive so do not use any capital letters.

<layer label="your layer name" type="feature" visible="true" autorefresh="30" disableclientcaching="true" mode="onDemand" />

you may have more attributes to your layer. I have set autorefresh property to 30 seconds.

This will refresh the map and add any new records to map. However it will not update the opened widget's data list. I think I need to write some more codes to refresh widget data. Anyone has experience in this to reload Query widget by getting layer property "autorefresh"  ? 

0 Kudos
MohammedKhamis
Emerging Contributor

Bjorn,

what about version 3.6 , is it can do that ?/

0 Kudos
AnthonyGiles
Honored Contributor

Yes from 3.1 onwards had that capability

0 Kudos