Secure editing in a mobile flex project

2783
17
Jump to solution
07-31-2013 05:12 AM
ClintonCooper1
New Contributor III
I have been running through the flex in a week tutorial and been playing around with developing a flex mobile app using snippets from flex api samples.  I found the Secure editing sample, and have been trying to run that in a flex mobile project.  However, I am running into an error when I run IdentityManager function in the code:

 <?xml version="1.0" encoding="utf-8"?> <s:View 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:esri="http://www.esri.com/2008/ags"   initialize="application1_initializeHandler(event)">    <fx:Script>   <![CDATA[    import com.esri.ags.components.IdentityManager;    import com.esri.ags.events.LayerEvent;    import com.esri.ags.geometry.MapPoint;    import com.esri.ags.layers.TiledMapServiceLayer;        import mx.events.FlexEvent;        protected function application1_initializeHandler(event:FlexEvent):void    {     IdentityManager.instance.enabled = true;    }        private function layerShowHandler(event:FlexEvent):void    {     // update the LODs/zoomslider to use/show the levels for the selected base map     var tiledLayer:TiledMapServiceLayer = event.target as TiledMapServiceLayer;     myMap.lods = tiledLayer.tileInfo.lods;    }    protected function marine_loadHandler(event:LayerEvent):void    {     myEditor.featureLayers = [ marine ];     myEditor.attributeInspector.fieldInspectors = [ creatorFI, typeFI ];    }   ]]>  </fx:Script> 



I get the runtime error of

 ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.  at flash.display::DisplayObjectContainer/getChildIndex()  at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::rawChildren_getChildIndex()  at mx.managers::SystemRawChildrenList/getChildIndex()  at spark.components.supportClasses::StyleableStageText/getFormIndex()  at spark.components.supportClasses::StyleableStageText/findTopmostForm()  at spark.components.supportClasses::StyleableStageText/updateProxyImageForTopmostForm()  at spark.components.supportClasses::StyleableStageText/commitProperties()  at mx.core::UIComponent/validateProperties()  at mx.managers::LayoutManager/validateClient()  at mx.managers::PopUpManagerImpl/addPopUp()  at mx.managers::PopUpManagerImpl/createPopUp()  at mx.managers::PopUpManager$/createPopUp()  at com.esri.ags.components::IdentityManager/popUpSignInWindow()  at com.esri.ags.components::IdentityManager/signIn()  at com.esri.ags.components::IdentityManager/doSignIn()  at com.esri.ags.components::IdentityManager/enqueue()  at Function/com.esri.ags.components:IdentityManager/getCredential/com.esri.ags.components:svcInfoResult2()  at mx.rpc::Responder/result()  at Function/<anonymous>()  at MyURLLoader/completeHandler()  at flash.events::EventDispatcher/dispatchEventFunction()  at flash.events::EventDispatcher/dispatchEvent()  at flash.net::URLLoader/onComplete() 


Is this an error due to the creation of a popup window on a cell device or is this just an error due to bad code writing?  the code works great in a windowed project, but causes this error on a mobile project.  Thanks in advance for helping me understand what is going on!

Clinton

After doing some more research on IdentityManager, I think the issue has something due to do with configuring PopUpManager.  But I am not yet there technically to understand it.  Thanks!
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
LloydHeberlie
Occasional Contributor
I have been running through the flex in a week tutorial and been playing around with developing a flex mobile app using snippets from flex api samples.  I found the Secure editing sample, and have been trying to run that in a flex mobile project.  However, I am running into an error when I run IdentityManager function in the code:

 <?xml version="1.0" encoding="utf-8"?> <s:View 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:esri="http://www.esri.com/2008/ags"   initialize="application1_initializeHandler(event)">    <fx:Script>   <![CDATA[    import com.esri.ags.components.IdentityManager;    import com.esri.ags.events.LayerEvent;    import com.esri.ags.geometry.MapPoint;    import com.esri.ags.layers.TiledMapServiceLayer;        import mx.events.FlexEvent;        protected function application1_initializeHandler(event:FlexEvent):void    {     IdentityManager.instance.enabled = true;    }        private function layerShowHandler(event:FlexEvent):void    {     // update the LODs/zoomslider to use/show the levels for the selected base map     var tiledLayer:TiledMapServiceLayer = event.target as TiledMapServiceLayer;     myMap.lods = tiledLayer.tileInfo.lods;    }    protected function marine_loadHandler(event:LayerEvent):void    {     myEditor.featureLayers = [ marine ];     myEditor.attributeInspector.fieldInspectors = [ creatorFI, typeFI ];    }   ]]>  </fx:Script> 



I get the runtime error of

 ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.  at flash.display::DisplayObjectContainer/getChildIndex()  at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::rawChildren_getChildIndex()  at mx.managers::SystemRawChildrenList/getChildIndex()  at spark.components.supportClasses::StyleableStageText/getFormIndex()  at spark.components.supportClasses::StyleableStageText/findTopmostForm()  at spark.components.supportClasses::StyleableStageText/updateProxyImageForTopmostForm()  at spark.components.supportClasses::StyleableStageText/commitProperties()  at mx.core::UIComponent/validateProperties()  at mx.managers::LayoutManager/validateClient()  at mx.managers::PopUpManagerImpl/addPopUp()  at mx.managers::PopUpManagerImpl/createPopUp()  at mx.managers::PopUpManager$/createPopUp()  at com.esri.ags.components::IdentityManager/popUpSignInWindow()  at com.esri.ags.components::IdentityManager/signIn()  at com.esri.ags.components::IdentityManager/doSignIn()  at com.esri.ags.components::IdentityManager/enqueue()  at Function/com.esri.ags.components:IdentityManager/getCredential/com.esri.ags.components:svcInfoResult2()  at mx.rpc::Responder/result()  at Function/<anonymous>()  at MyURLLoader/completeHandler()  at flash.events::EventDispatcher/dispatchEventFunction()  at flash.events::EventDispatcher/dispatchEvent()  at flash.net::URLLoader/onComplete() 


Is this an error due to the creation of a popup window on a cell device or is this just an error due to bad code writing?  the code works great in a windowed project, but causes this error on a mobile project.  Thanks in advance for helping me understand what is going on!

Clinton

After doing some more research on IdentityManager, I think the issue has something due to do with configuring PopUpManager.  But I am not yet there technically to understand it.  Thanks!



Hi Clinton,

Sorry it took me so long to get this to you.  Here is a sample that should help get you going with secure mobile editing.  https://github.com/lheberlie/building-mobile-apps-flex/tree/develop/samples/secure-mobile-editing/sr...
I used Adobe Flex SDK 4.6.0 with AIR SDK 3.8 overlay when testing this sample.

View solution in original post

0 Kudos
17 Replies
DasaPaddock
Esri Regular Contributor
What version of AIR are you using and what device are you testing this on?
0 Kudos
DasaPaddock
Esri Regular Contributor
Also what version of the Flex SDK are you using?

It looks like the error may be coming from StyleableStageText.
0 Kudos
ClintonCooper1
New Contributor III
Also what version of the Flex SDK are you using?

It looks like the error may be coming from StyleableStageText.


Flash Builder 4.7 with Flex SDK 4.6 through air 3.4.  I am running this code through Flash Builder on an Air simulator android device (incredible 2).  I have not yet tried it on my actual phone as I am just trying some different things. 

I get it to run once...when I first start up flash builder.  However, subsequent runs I get this error.

I also have the mx.swc and sparkskins.swc added to the build path.
0 Kudos
DasaPaddock
Esri Regular Contributor
Can you try AIR 3.8?
0 Kudos
ClintonCooper1
New Contributor III
Updated to air 3.8 and still getting the same error.
0 Kudos
ClintonCooper1
New Contributor III
I have attached my full code in hopes of finding the reason for the error.  I do not have any other relevant code in the viewnavigator.mxml


<?xml version="1.0" encoding="utf-8"?>
<s:View 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:esri="http://www.esri.com/2008/ags"
  initialize="application1_initializeHandler(event)">
 
 <fx:Script>
  <![CDATA[
   import com.esri.ags.components.IdentityManager;
   import com.esri.ags.events.LayerEvent;
   import com.esri.ags.geometry.MapPoint;
   import com.esri.ags.layers.TiledMapServiceLayer;
   
   import mx.events.FlexEvent;
   
   protected function application1_initializeHandler(event:FlexEvent):void
   {
    IdentityManager.instance.enabled = true;
   }
   
   private function layerShowHandler(event:FlexEvent):void
   {
    // update the LODs/zoomslider to use/show the levels for the selected base map
    var tiledLayer:TiledMapServiceLayer = event.target as TiledMapServiceLayer;
    myMap.lods = tiledLayer.tileInfo.lods;
   }
   protected function marine_loadHandler(event:LayerEvent):void
   {
    myEditor.featureLayers = [ marine ];
    myEditor.attributeInspector.fieldInspectors = [ creatorFI, typeFI ];
   }
  ]]>
 </fx:Script>
 
 <fx:Declarations>
  <esri:Extent id="initialExtent"
      xmin="-13449015" ymin="4182302" xmax="-13433803" ymax="4191340">
   <esri:SpatialReference wkid="102100"/>
  </esri:Extent>
  <!-- FieldInspector for the 'creator' field -->
  <esri:FieldInspector id="creatorFI"
        featureLayer="{marine}"
        fieldName="creator"
        label="Biologist"/>
  <esri:FieldInspector id="typeFI"
        featureLayer="{marine}"
        fieldName="type"
        label="Sighting"/> 
 </fx:Declarations>
 
 
 <esri:Map id="myMap"
     level="4"
     load="myMap.centerAt(new MapPoint(-11713000, 4822000))">
  <esri:ArcGISTiledMapServiceLayer show="layerShowHandler(event)"
           url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"
           visible="{bb.selectedIndex == 0}"/>
  <esri:ArcGISTiledMapServiceLayer show="layerShowHandler(event)"
           url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"
           visible="{bb.selectedIndex == 1}"/>
  <esri:FeatureLayer id="marine" name="SaveTheBay-Marine"
         load="marine_loadHandler(event)"
         mode="snapshot"
         outFields="[type, confirmed, comments, creator]"
         url="http://sampleserver6.arcgisonline.com/arcgis/rest/services/SaveTheBay/FeatureServer/0"/>
 </esri:Map>
 <s:ButtonBar id="bb"
     right="0"
     requireSelection="true">
  <s:dataProvider>
   <s:ArrayList>
    <fx:String>Street</fx:String>
    <fx:String>Imagery</fx:String>
   </s:ArrayList>
  </s:dataProvider> 
 </s:ButtonBar>
 
 <esri:Editor id="myEditor"
     width="100%" height="75"
     geometryService="{new GeometryService('http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer')}"
     includeInLayout="false"
     map="{myMap}"
     visible="true"/>
 <esri:Geocoder width="200" height="30"
       bottom="5"
       horizontalCenter="0"
       map="{myMap}"/>
</s:View>

0 Kudos
DasaPaddock
Esri Regular Contributor
Does it work one time, every time you start Flash Builder? It may be a bug in the simulator. Can you try on a device?
0 Kudos
ClintonCooper1
New Contributor III
Just tried it on my device, and it worked flawlessly the first time.  However after closing the app (stopping the program completely), I reopened it, and could not get anything (just a screen with a few buttons, but no login screen). 

Clinton
0 Kudos
DasaPaddock
Esri Regular Contributor
Which device did you test it on?

There is an option to not show the sign in as a pop-up. You can listen for the "showSignInWindow" event and then call event.preventDefault().

See:
https://developers.arcgis.com/en/flex/api-reference/com/esri/ags/components/IdentityManager.html#eve...

You then could show the sign in form in a new View. See the source for the default form in the skins folder at:
com/esri/ags/skins/supportClasses/SignInWindow.mxml
0 Kudos