Open the flex viewer. Open the edit widget. You can edit.
Open the flex viewer. Open the search widget. You can search.
Open the flex viewer. Open the edit widget. Open the search widget. You can edit. You can search.
Open the flex viewer. Open the search widget. Open the edit widget.
Edit widget is broken.
Open the flex viewer. Open the search widget. Do a search. Open the edit widget. You can edit.
I am using the uncompiled flex viewer 3.3 pulled from GitHub. I haven't merged changes for a couple weeks.
It appears to be an issue with a feature layer being added to the viewer by the search widget that is totally null in it's attributes until a search is completed. The edit widget makes it though this section of code gracefully, but returns without going through all the layers since the first one it finds is null (url=null, loaded=null, loadfault=null).
Code:
var layer:Layer = arrLayers[index] as Layer;
if (layer.loaded)
{
if ((layer is FeatureLayer && layer.name.indexOf("hiddenLayer_") == -1) && FeatureLayer(layer).isEditable && !FeatureLayer(layer).featureCollection)
{
layer.removeEventListener(FeatureLayerEvent.SELECTION_COMPLETE, featureLayer_selectionComplete);
layer.addEventListener(FeatureLayerEvent.SELECTION_COMPLETE, featureLayer_selectionComplete, false, 1);
featureLayers.push(layer);
arrFinalLayers.push(layer);
index++;
getAllFeatureLayers(index, featureLayers);
}
else if (layer is ArcGISDynamicMapServiceLayer && layer.name.indexOf("hiddenLayer_") == -1)
{
createFeatureLayersFromDynamicMapService(ArcGISDynamicMapServiceLayer(layer), index);
}
else
{
index++;
getAllFeatureLayers(index, featureLayers);
}
}
else if (layer.loadFault)
{
index++;
getAllFeatureLayers(index, featureLayers);
}
else
{
// listen for load
layer.addEventListener(LayerEvent.LOAD, layerLoadHandler);
}
Can anyone else duplicate this behavior? I noticed it because I have a custom search widget that gets loaded during the initial load app the app (preload=open) and just added the edit widget to my viewer and it broke my workflow.
If this is a problem my personal suggestion would be to fix this in the edit widget so that it can continue on past this bad layer. My first attempt at a quick fix is to add one more else if block to continue checking layers if you still have more to go. Not sure if it fits the logic, but works with very preliminary testing.
Code:
else if (index < arrLayers.length-1)
{
index++;
getAllFeatureLayers(index, featureLayers);
}