Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import Javascript file into Camunda embedded forms

Tags:

tomcat

camunda

I've been asked to maintain some Camunda embedded forms (here's the documentation) to allow the user to upload files and to delete any of the existing ones. I've almost finished it in one of the forms and I have to apply the same changes to eleven more. I'd like to create an script file with the shared Javascript code to import it instead of embedding it again on all the forms but I can't find anything in the docs or elsewhere.

I tried creating the Javascript file in the following places:

  • In the same folder of the forms (src/main/webapp/forms/custom.js)
  • Inside the resources folder (src/main/resources/custom.js)
  • Inside META-INF folder (src/main/resources/META-INF/custom.js)

In all cases, I can't reach the scripts file from the forms, neither from the URL of the browser. I'm completely new to Camunda so I'm a little lost on this...

Any suggestions? Thanks in advance,

like image 618
Fel Avatar asked Feb 18 '26 01:02

Fel


1 Answers

I located my custom Javascript-files within my project as follows:

src/main/webapp/scripts/test.js

In my embedded form I then import my script:

<form>
    //Your form elements
    <script src="../../../../name-of-war-folder/scripts/test.js"></script>
</form>

Then I am able to call my custom functions.

I think this is because the embedded forms are included from somewhere within the tasklist folder of the camunda application apache-tomcat\webapps\camunda\app\tasklist

An alternative would be to put the custom Javascript-files into the apache-tomcat\webapps\camunda\app\tasklist\scripts folder and import it with:

<script src="../scripts/test.js"></script>

Unfortunately I have not found an easier way yet to include the scripts, but at least this works for now.

Edit: I found out an easier way to include the scripts which are located under:

src/main/webapp/scripts/test.js

Simply using the tag:

<script src="/name-of-war-folder/scripts/test.js"></script>
like image 169
marketmi Avatar answered Feb 20 '26 21:02

marketmi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!