Enabling a Custom Geoprocessing Widget in WAB Fails

2052
11
09-05-2019 09:59 AM
MichaelCollins6
New Contributor II
Hi all:
I am getting the following error when attempting to publish a widget to WAB in our Enterprise Portal. The file is definitely there so I am hoping this is a simple issue, but am utterly stuck. This was replicated using the stock geoprocessing widget as well by publishing that to the same server.
GET https://maps.gpinet.com/Test/widgets/Geoprocessing/nls/strings net::ERR_ABORTED 404 (Not Found)
init.js:37 Error: scriptError at c (init.js:11) at HTMLScriptElement.<anonymous> (init.js:35)
init.js:37 src: dojoLoader
init.js:37 info:
  1. (2) ["https://maps.gpinet.com/Test/widgets/Geoprocessing/nls/strings", Event]
    1. 0: "https://maps.gpinet.com/Test/widgets/Geoprocessing/nls/strings"
    2. 1: Event {isTrusted: true, type: "error", target: script, currentTarget: null, eventPhase: 0, …}
    3. length: 2
    4. __proto__: Array(0)
11 Replies
DavidWilton
Occasional Contributor

The problem here is that when you publish a widget into Portal its hosted outside the WAB and you run into issues with paths. Widgets/MyWidget will no longer work. I'm not 100% sure on i18n, it always seems to work differently with paths to other dojo require items. Anyway I ran into the same issue with the AddData widget so here is what I think. With the geoprocessing widget I see:

RecordSetEditorChooser.js: 26

'dojo/i18n!../nls/strings',

Here there is a path and it is failing to find it, the error message is misleading I think its actually looking for it in the WAB. There should be a way to make it work as a relative path but I'm not sure what it is. I ended up just requiring the js file relatively (so no i18n):

'./nls/strings',

then using the .root property:

RecordSetEditorChooser.js: 38

lang.mixin(this.nls, gpNls.root);

This means your localisation won't work, but at least the widget may work...

With the add data widget there were lots of data-dojo-type within the templates. Remember "widgets" no longer works as a path, this is looking in the widgets folder of the WAB, not local to your widget. To fix this I ended up removing the data-dojo-type and creating the widgets within widget.js. Hoepfully you won't have to do this and it will be the simple one line fix above (because this is a nightmare)

data-dojo-type="widgets/AddData/search/ScopeOptions"

The main point is that you have to get into the mindset that everything must work relatively if you are going to host the widget for portal

ØysteinKristoffersen
New Contributor II

Hi, I have the exact same issue with the AddData widget. Could you possibly share your code if you managed to get it working?

DavidWilton
Occasional Contributor

Completely hacked together, but it it should work at least

Dropbox - AddDataPortal.zip - Simplify your life 

ØysteinKristoffersen
New Contributor II

Thank you very much! I am unfortunatley not able to download the zip-file from that link. Could you try share the file again? Otherwise you could send it to my email perhaps

0 Kudos
DavidWilton
Occasional Contributor

Sorry try again. If this doesn't work drop me a PM on linked in (I don't think you can PM on geonet? 

Dropbox - AddDataPortal.zip - Simplify your life 

https://www.linkedin.com/in/davidjwilton/ 

ØysteinKristoffersen
New Contributor II

I managed to download now! Thank you for helping out!

0 Kudos
DavidWilton
Occasional Contributor

Øystein, I realised there was an issue with the NLS if you were using the "add from file" option. updated here

Dropbox - AddDataPortal.zip - Simplify your life 

0 Kudos
Vara_PrasadM_S
Occasional Contributor II

Thank you very much!

It helped me a lot.

0 Kudos
WenhaoWu
New Contributor

Hi @DavidWilton thank you so much for sharing your widget code. I have the exactly the same issue and have been stuck with this for days...

Could you clarify what you did to get it to work was ONLY replacing the original "dojo/i18n!../nls/strings" to ".nls/strings" and creating local nls folders with those translation files?

Do I also need to make these two changes? If necessary, where do I look for these two places to change?

- the RecordSetEditorChooser.js: 38 change "lang.mixin(this.nls, gpNls.root)"

- data-dojo-type="widgets/AddData/search/ScopeOptions"

 

Many thanks!

Wen

0 Kudos