Select to view content in your preferred language

TypeError: clazz is not a constructor, not sure what the issue is?

1894
2
03-07-2019 04:09 AM
JamesHone1
New Contributor III

hi Im trying to adjust the example ShowVertex feature action to suite my porposes  by adding another feature action to the demo widget and send the name and ID of a feature to the widget.

I have , heres my feature action code

define([
   'dojo/_base/declare',
   'jimu/BaseFeatureAction',
   'jimu/WidgetManager'],
   function(declare, BaseFeatureAction, WidgetManager){
      var clazz = declare(BaseFeatureAction, {

      iconFormat: 'png',

      isFeatureSupported: function(featureSet){
         return featureSet.features.length > 0 && featureSet.features[0].geometry.type !== 'point';
      },

      onExecute: function(featureSet){
         WidgetManager.getInstance().triggerWidgetOpen(this.widgetId)
         .then(function(myWidget) {
            var id
            var name
         featureSet.features.forEach(function(f){
            id = f.id
            name = f.name
         });
      myWidget.AddtoSelected(name,id);
   });
   }
});
return clazz;
});


Im getting a create widget error

when debuggin in chrome I get

init.js:115 TypeError: clazz is not a constructor
at Object.createWidget (WidgetManager.js?wab_dv=2.11:321)
at Object.<anonymous> (WidgetManager.js?wab_dv=2.11:113)
at init.js:64
at l (init.js:108)
at e.then.b.then (init.js:111)
at Object.<anonymous> (WidgetManager.js?wab_dv=2.11:111)
at init.js:64
at l (init.js:108)
at b.extend.then.then.b.then (init.js:111)
at Object.loadWidget (WidgetManager.js?wab_dv=2.11:108) "TypeError: clazz is not a constructor
at Object.createWidget (https://l050736:3344/webappbuilder/apps/11/jimu.js/WidgetManager.js?wab_dv=2.11:321:16)
at Object.<anonymous> (https://l050736:3344/webappbuilder/apps/11/jimu.js/WidgetManager.js?wab_dv=2.11:113:35)
at https://js.arcgis.com/3.27/init.js:64:337
at l (https://js.arcgis.com/3.27/init.js:108:277)
at e.then.b.then (https://js.arcgis.com/3.27/init.js:111:152)
at Object.<anonymous> (https://l050736:3344/webappbuilder/apps/11/jimu.js/WidgetManager.js?wab_dv=2.11:111:47)
at https://js.arcgis.com/3.27/init.js:64:337
at l (https://js.arcgis.com/3.27/init.js:108:277)
at b.extend.then.then.b.then (https://js.arcgis.com/3.27/init.js:111:152)
at Object.loadWidget (https://l050736:3344/webappbuilder/apps/11/jimu.js/WidgetManager.js?wab_dv=2.11:108:12)
----------------------------------------
rejected at Object.<anonymous> (https://l050736:3344/webappbuilder/apps/11/jimu.js/WidgetManager.js?wab_dv=2.11:126:21)
at https://js.arcgis.com/3.27/init.js:64:337
at l (https://js.arcgis.com/3.27/init.js:108:277)
at e.then.b.then (https://js.arcgis.com/3.27/init.js:111:152)
at Object.<anonymous> (https://l050736:3344/webappbuilder/apps/11/jimu.js/WidgetManager.js?wab_dv=2.11:111:47)
at https://js.arcgis.com/3.27/init.js:64:337
at l (https://js.arcgis.com/3.27/init.js:108:277)
at b.extend.then.then.b.then (https://js.arcgis.com/3.27/init.js:111:152)
at Object.loadWidget (https://l050736:3344/webappbuilder/apps/11/jimu.js/WidgetManager.js?wab_dv=2.11:108:12)
at Object.<anonymous> (https://l050736:3344/webappbuilder/apps/11/jimu.js/BaseWidgetPanel.js?wab_dv=2.11:76:28)
----------------------------------------
Error
at Object.loadWidget (https://l050736:3344/webappbuilder/apps/11/jimu.js/WidgetManager.js?wab_dv=2.11:96:17)
at Object.<anonymous> (https://l050736:3344/webappbuilder/apps/11/jimu.js/BaseWidgetPanel.js?wab_dv=2.11:76:28)
at Object.forEach (https://js.arcgis.com/3.27/init.js:71:486)
at Object.loadAllWidgetsInOrder (https://l050736:3344/webappbuilder/apps/11/jimu.js/BaseWidgetPanel.js?wab_dv=2.11:66:13)
at Object.startup (https://l050736:3344/webappbuilder/apps/11/jimu.js/BaseWidgetPanel.js?wab_dv=2.11:55:12)
at Object.d (https://js.arcgis.com/3.27/init.js:198:400)
at Object.startup (https://l050736:3344/webappbuilder/apps/11/jimu.js/OnScreenWidgetPanel.js?wab_dv=2.11:67:14)
at Object.openPanel (https://l050736:3344/webappbuilder/apps/11/jimu.js/PanelManager.js?wab_dv=2.11:152:17)
at Object.<anonymous> (https://l050736:3344/webappbuilder/apps/11/jimu.js/PanelManager.js?wab_dv=2.11:93:16)
at https://js.arcgis.com/3.27/init.js:64:337"

As this error report doesnt mention any of my widget files Im rather confused on where to find the problem, Im assuming its in the feature action as thats where clazz is.

Could someone help point me in the right direction to resolve this error?

Thanks

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus

James,

  Normally this means you have introduced a syntax error in your code, not closed a bracket, forgot a comma, etc. What does your mainifest.json look like? What does your Widget.js look like?

JamesHone
New Contributor

thanks I will take a look at those 2 files for syntax

0 Kudos