ngramsky

Help with SDE / Javsscript API

Discussion created by ngramsky on Feb 24, 2011
Latest reply on Apr 22, 2011 by strainryan
Forum masters, please help!

I've installed ArcSDE and built my first feature layer.  I'm trying to mimic what Esri shows in their JavaScript API Samples to edit attributes.  This is the page I am trying to mimic:  http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/ed_attribute_inspector.html

If I have a maplayer and a feature layer, I should be able to simply replace my map and feature layers in this example, correct? 

Everything looks to be working as:
- map loads well
- when I click on a feature set item (I have a feature set that contains polygons that are shapes of a building) an edit widget pops up with the correct data from the database.

However, after I make edits and close out the box I get the following error in my mozilla error console:

"this._features is null"  and it is referencing the Attribute-all.xd.js file contained in the online 2.1 API.

Does anyone have any ideas where I may be going wrong?
How can I debug this?  I do not see any logs that are logging this transaction or an error, though I am still very new and could be missing something.
Is my database set up wrong?  If so, how would I know?  I don't see any transactions making it to the database.

I imported an existing ArcMap datafile to my SDE database, saved that to an .mxd file and created my Feature Layer from that.  Creating such a feature layer does also give me a MapServiceLayer, correct?

The basemap I am using is an ArcGISDynamicMApServiceLayer instead of the Tiled map in the example.  That shouldn't matter, should it?

I've attached my modifed code as well.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
   <meta http-equiv="X-UA-Compatible" content="IE=7" />
   <!--The viewport meta tag is used to improve the presentation and
behavior of the samples
     on iOS devices-->
   <meta name="viewport" content="initial-scale=1,
maximum-scale=1,user-scalable=no"/>
   <title>Editable FeatureLayer in Selection Only Mode with Attribute
Inspector</title>
   <link rel="stylesheet" type="text/css"
href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.1/js/dojo/dijit/themes/claro/claro.css">
   <style>
     .dj_ie .infowindow .window .top .right .user .content { position:
relative; }
     .dj_ie .simpleInfoWindow .content {position: relative;}
   </style>
   <script type="text/javascript">
     var djConfig = {parseOnLoad: true};
   </script>
   <script type="text/javascript"
src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.1"></script>

   <script type="text/javascript" language="Javascript">
     dojo.require("esri.map");
     dojo.require("esri.dijit.AttributeInspector-all");
     var ESRI_URL =
'http://oitsap041v/ArcGIS/rest/services/nick_test/MapServer/';


     function init() {
       //This sample requires a proxy page to handle communications with
the ArcGIS Server services. You will need to
       //replace the url below with the location of a proxy on your
machine. See the 'Using the proxy page' help topic
       //for details on setting up a proxy page.


       var map = new esri.Map("mapDiv");
       dojo.connect(map, "onLayersAddResult", initSelectToolbar);
       var basemapURL= ESRI_URL;

       var basemap = new
esri.layers.ArcGISDynamicMapServiceLayer(basemapURL);
       map.addLayer(basemap);

       var buildingOutlinesMSL = new
esri.layers.ArcGISDynamicMapServiceLayer(
               "http://oitsap041v/ArcGIS/rest/services/test_building_sde/MapServer");
       buildingOutlinesMSL.setDisableClientCaching(true);
       map.addLayer(buildingOutlinesMSL);

       var petroFieldsFL = new esri.layers.FeatureLayer(
               "http://oitsap041v/ArcGIS/rest/services/test_building_sde/FeatureServer/0",
{
         mode: esri.layers.FeatureLayer.MODE_SELECTION,
         outFields: ['*']
       });
       var selectionSymbol = new
esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_NULL,
                new esri.symbol.SimpleLineSymbol("dashdot", new
dojo.Color("yellow"), 2),null);
       petroFieldsFL.setSelectionSymbol(selectionSymbol);
       dojo.connect(petroFieldsFL, "onEditsComplete", function() {
         buildingOutlinesMSL.refresh();
       });
       map.addLayers([petroFieldsFL]);

       map.infoWindow.setContent("<div id='attrInspector'></div>");
       map.infoWindow.resize(375,250);
     }

     function initSelectToolbar(results) {
       var map = this;
       var petroFieldsFL = results[0].layer;
       var selectQuery = new esri.tasks.Query();

       dojo.connect(map, "onClick", function(evt) {

         selectQuery.geometry = evt.mapPoint;
         petroFieldsFL.selectFeatures(selectQuery,
esri.layers.FeatureLayer.SELECTION_NEW, function(features) {

           if (features.length > 0) {
             map.infoWindow.show(evt.screenPoint,map.getInfoWindowAnchor(evt.screenPoint));
           } else {
             map.infoWindow.hide();
           }
         });
       });

       dojo.connect(map.infoWindow, "onHide", function() {
         petroFieldsFL.clearSelection();
       });

       var attInspector = new
esri.dijit.AttributeInspector({layerInfos:[{'featureLayer':petroFieldsFL}]},
"attrInspector");
       dojo.connect(attInspector, "onDelete",function(feature){
         feature.getLayer().applyEdits(null,null,[feature]);
         map.infoWindow.hide();
       });
       dojo.connect(attInspector, "onNext", function(feature) {
         var screenPoint =
map.toScreen(feature.geometry.getExtent().getCenter());
         map.infoWindow.show(screenPoint,map.getInfoWindowAnchor(screenPoint));
       });

       dojo.connect(attInspector, "onAttributeChange",
function(feature,fieldName,newFieldValue) {
alert("Should change");
         feature.attributes[fieldName] = newFieldValue;
         feature.getLayer().applyEdits(null, [feature], null);
       });
     }

     dojo.addOnLoad(init);
   </script>

</head>
<body class="claro">
   <div id="mapDiv" style="width:800px; height:600px; border:1px solid
#000;"></div>
   Click on Field to update its product.
</body>
</html>

Outcomes