EventScripts - Multiple contentId's in one File

Background

EventScripts offer far greater flexibility and possibilities than graphical event bindings.
Up tu now, our projects where built out of one event binding for each logical software module. This software module consisted of a wide variety of content, all of which was then controlled and referenced within a single event binding file.

Problem

In the EventScript, you must now specify a Content ID using an annotation to which the file refers.
This Content ID is then also created as a separate JavaScript file on the mappView server.
image

As only one piece of content can be specified per file, a separate EventScript must now be created for each piece of content in the software module, and these must then be specified accordingly in the vis file.
This results in a much larger number of files and a much more confusing vis file.
In our view, this is a major disadvantage compared to graphical event bindings.

Question

Does anyone know if there is a way to handle multiple pieces of content within the same EventScript file, or if there are plans to make this more flexible so that we don’t have to create so many files and reference them in the vis file?

Maybe I can bring some insights here …

Does anyone know if there is a way to handle multiple pieces of content within the same EventScript file, or if there are plans to make this more flexible

While I can understand the question, I need to say, that it is currently technically not possible to support this. The reason is, that the mapp View artefacts are not “global”.

We need to have the contentId in the file - otherwise the editor would not know, which widgets can be referred to.

Simple example:

/**
* @eventScriptSetId ContentRecipe
* @contentId myContent
*/
widgets.myWidget.click(function(e) {
...
});

As “myContent” is specified in this script, the editor - and also the runtime - knows, that “myWidget” is actually “myContent.myWidget” … which means, the editor can verify the usage, the compile can verify it, too and also the runtime knows what you mean.

If we would allow to refer more than one content in a script (or even would remove the need to specify the content), things would be not so easy anymore. The widget names are only unique per content, so “myWidget” could be almost on any content … the editor would not know what you mean, same for compiler and runtime …

In the end you would end up with something like this:

/**
* @eventScriptSetId ContentRecipe
*/
myContent.widgets.myWidget.click(function(e) {
...
});

… you’d need to prefix each widget with the content.

We did not go this road, as we saw the scripts are counter part to the event-bindings … and event-bindings you usually have also per content.

So to answer you question:
It is not possible to bypass this limitation somehow … and there is also no future plan to change this behavior.

Hi Christian

Thanks for your answers.
What you’ve said confirms my suspicions.

We hoped, thatit is possible to split the file with several coment sections .
Something like this, for example.

/*
* @eventScriptSetId ContentRecipe
* @contentId myContentOne
*/

// click event of widget on myContentOne
widgets.myWidget.click(function(e) {
  ...
});

/*
* @contentId myContentTwo
*/

// click event of widget on myContentTwo
widgets.myWidget.click(function(e) {
  ...
});

However, as you have stated that this is not supported, we will implement it using a number of additional files.

Thanks and best regards
<°///—<