Select to view content in your preferred language

Why is a widget's config file name based on the label attribute?

4258
3
Jump to solution
02-25-2015 01:22 PM
MichaelJenkins
Frequent Contributor

I have a question about widgets in the WAB.  Why is the config file based on the widget's label instead of its name?

If the widget is named "eSearch" and I change the label to something else that I think my users will better understand, like "Search & select", why does the json config file in the configs folder change to match the new label name?

It seems to me that the label property should just be used for the text that is displayed to the user while the name attribute would be used by the code to identify the widget. 

This is not an eSearch question specifically, the out of the box widgets do this too. When this happens, your config file no longer matches the widget's folder name or name attribute.

GISP
Tags (3)
0 Kudos
1 Solution

Accepted Solutions
MichaelJenkins
Frequent Contributor

I figured out the answer to my own question.   The config file name is based on the widget's label so that you can add more than one instance of the same widget.  To add a second instance of the same widget, for example the draw widget, you have to give the second one a different name which is its label property.   By having the config file named by label, then, the same widget can be used more than once with different configurations.

  Fig5.png

I can imagine wanting to add more than one GeoProcessing widget, for example, with each pointing to a different GP service.   This way you don't have to load two entire copies of the widget.

GISP

View solution in original post

3 Replies
RobertScheitlin__GISP
MVP Emeritus

Michael,

   What I am seeing is that the widgets label is just what is displayed to the end user. The widgets actual folder name and config name does not change based on that label and in my opinion it should not. Developers sometime hard code asset paths in their widgets that would get broke if the widget folder name changed. As far as the config file name I don't see the logic in changing it with the label, most users are not going to be digging into the config file.

MichaelJenkins
Frequent Contributor

Robert,

Right, the widget folder doesn't change name, just the configuration json file for it.  To clarify my question, the default config json file is in the widget folder, but as soon as you start changing the widget configuration, it writes a different json config file into the "configs" folder with a sub folder that has the widget name.  That config file name is based on the widget's label.

Using the "Coordinate" widget as an example, when you add the widget to your WAB application, there is no corresponding "coordinate" folder under the "configs" folder. (in fact there won't even be a configs folder yet). The widget is looking at the config.json file in the widget's own folder.

Fig1.png

Now click the edit icon on the widget and change the number of decimal places or add another coordinate system.  Save the app and a "configs" folder gets created with a "Coordinate" folder and a file called "config_Coordinate.json".

Fig2.png

Next, click the edit icon again but this time change the widget's name to something different, like "DevSummitDemo" and the config_Coordinates.json file changes its name to "config_DevSummitDemo".

Fig3.png

This config file doesn't even contain the label for the widget.  That is in the "config.json" in the root folder.  When you change the name of the widget it changes the "label" and "config" attributes in that root config.json file, with the "config" attribute containing the path to the file I'm describing above.

Fig4.png

The same thing happens with other widgets, including eSearch so I guess it is built into the widget template.

(Sorry to use the word "config" so many times in one post.)

GISP
0 Kudos
MichaelJenkins
Frequent Contributor

I figured out the answer to my own question.   The config file name is based on the widget's label so that you can add more than one instance of the same widget.  To add a second instance of the same widget, for example the draw widget, you have to give the second one a different name which is its label property.   By having the config file named by label, then, the same widget can be used more than once with different configurations.

  Fig5.png

I can imagine wanting to add more than one GeoProcessing widget, for example, with each pointing to a different GP service.   This way you don't have to load two entire copies of the widget.

GISP