I'm building a web app with Diagram in it.
For the diagram I used jsPlumb library Link: https://jsplumbtoolkit.com/
One of my requirement is to make Blocks inside the Diagram like flowchart. And one type of the blocks is a able to be inserted by customizable script. So, when user double-clicked that block, they can input Javascript code in the textarea and will be executed later.
Here lies my problem : I able to run the script code very well, when it is still on the front-end side (jsp) using browser using "new Function" from Javascript. But after the block is saved, the script saved to DB. And if I need to run it again, then it will be executed from back-end (Java).
Therefore, I used ScriptEngine to run the Javascript. The problem is ajax, $-sign, console, etc are not recognized from Java. And I found out later, that ScriptEngine did not support for those kind of things.
So, I wonder is there is any possible way to make these possible ? I'm open to other alternative idea.
Thank you