Get context path in every embedded forms.

663 views
Skip to first unread message

Emerald Hieu

unread,
Dec 18, 2014, 2:04:15 AM12/18/14
to camunda-...@googlegroups.com
Hi,

Following this guide, I'm trying to get context path using AngularJS. Based on that context path, I include a JS file that contains JQuery scripts.
The problem is the JS file has been included but the script doesn't run. I wonder if the merging of AngularJS and JS caused the problem.

1) Can I use JQuery $.ajax() to get the context path? If so, what's the rest engine URI should I pass? How can I do it if I don't have a context path to prepend it to "engine-rest/engine/default/task/.../form"?
2) Do every pages must include this script to get context path before including <script>, <link> or <img>? Is there a way to reuse it?

test.html
<form role="form" class="form-horizontal">

<script cam-script type="text/form-script">
inject(['$http', 'Uri', function($http, Uri) {
camForm.on('form-loaded', function() {
$http.get(Uri.appUri("engine://engine/:engine/task/" + camForm.taskId + "/form")).success(function(result){
$scope.contextPath = result.contextPath;
});
});
}]);

$scope.getPath = function (path) {
  return $scope.contextPath + path;
};
</script>

<script type="text/javascript" ng-src="{{getPath('/resources/js/my-app/test.js')}}"></script>

</form>

Inspect Element, it gives

<script type="text/javascript" ng-src="/my-app/resources/js/test.js" src="/my-app/resources/js/test.js"></script>


test.js

alert('something');


Tags: embedded form, Camunda 7.2 JBoss distribution, AngularJS, JQuery.

Thank you and Merry Christmas,
Emerald Hieu

Valentin Vago

unread,
Dec 18, 2014, 6:23:06 AM12/18/14
to camunda-...@googlegroups.com
Hi,

we believe that it is not a really good thing to load additional scripts from the form itself.
If you need additional scripts, you should rather customize the build (it can be done in multiple ways, the easiest one seems to just add a script tag at the end of the index.html).

A client asked for something similar and we are working on a example. I will keep you in touch.

All the best,
Valentin 

Daniel Meyer

unread,
Dec 19, 2014, 11:37:37 AM12/19/14
to camunda-...@googlegroups.com
And here it is:


Will only be possible with camunda 7.3.0, however.

Daniel

Bernd Rücker

unread,
Oct 9, 2015, 8:06:52 AM10/9/15
to camunda BPM users
I found this post when searching for the same thing.

As far as I understand I currently CANNOT load additional scripts in a task form - correct?

I think this IS a valid use case - as anything else means you need to adjust the overall tasklist, which might not be possible - but you still want to add new stuff in your own task form (which is part of the process application deployment - not the tasklist deployment itself).
Reply all
Reply to author
Forward
0 new messages