I have several javascript files in my resources, and i have them called from my global process pages as -script type=“text/javascript” src=“…js”–/script-.
The javacripts load successfully in the browser via the /aplicationResourceLocation/location = … , but the process forms web pages sometimes appear to not take some of them (arbitrary ones) into account (it acts as if those javascript weren t load) and, other times everything works like a charm for the exactly same use case… I didnt find any reason nor pattern for the errror to occur.
Any known similar issues ?
It looks like dynamical javascript file load were used in BonitaSoft, i m not sure of that (so the “look likes” ), and in such case load order and synchronization is higly dependent on the Browser.
The process layout is dynamically loaded. So yes, if you add scripts in them, they are dynamically added to the DOM as well.
If this is an issue, you can directly add your scripts in tomcat/bonita/client/tenants/1/work/theme/portal/BonitaForm.html. It is the entry point for the forms and it is not loaded dynamically.
If you are using the subscription version, you can create a new portal looknfeel and edit this file in the looknfeel to avoid having to access the file system.
It s easy to reproduce, generate about 15 javascript files (each ones about 50 kB), include dependencies between them:
file1.js:
(function( file1Library, $, undefined ) {
}( window.file1Library = window.file1Library || {}, jQuery ));
etc…
file2.js:
if (typeof file1Library === “undefined” || ) {
throw “file1Library2 requires library file1Library1”;
}
etc…
Include them in bonitasoft portal (in adecuate order of dependencies…) and trace your browser, see how randomly appear the exceptions …
Why are you using 15 files for dependent code? This seems like a problem waiting to happen.
I would pull all this dependent scripts together into one file and then use a MINIFY-er to reduce the size of the file and load only this one.
I suspect the problem could be that the browser loader is simply being overwhelmed and is getting scripts out of order regardless of in sequence file order.
That s what i do, but i gave you a use case that clearly reproduces the problem. The problem also appears randomly with three minified .js, but less often.
Try it on firefox. It looks like dynamical javascript file load were used in BonitaSoft, i m not sure of that (so the “look likes” ), and in such case load order and synchronization is higly dependent on the Browser.
must admit I don’t use FF, haven’t since chrome came out.
Anyway - a quick google later I saw these two articles that may be of some help, or at least explain what is happening, otherwise I’ve nothing else I can provide…
I m not thinking about rewritting the way bonitasoft loads the javascript files … Just thinking in using it…
I already know these tecnics.
Anyway, Thanks to you.
You might have a lot of problem for that in the future if people use widget to personalize their interface… We currently use it with slickgrid and this problem is quite perturbing, i ll try adding common libraries to the BonitaForm.html, but of sure some of them only depends on the process…
Thanks.
Same with 6.5.1 (or course, as it seems to be a ‘feature’).
I got exactly the same, I wanted to load SlickGrid (because Bonita’s version of an Editable Grid is broken in several browsers and anyway slightly ugly), it didn’t work, and then I lost several precious hours figuring out that Bonita was not loading the scripts (or other external resources) as designed in the Form customization but asynchronously.
Then I searched for a settings that would disable this asynchronous loading, no luck.
Then I found this ticket. Thank you @anthony for the advice and the explanation !
Of course, the drawback of this procedure is that the customization must be applied in each installation of Bonita (development, production, next version) and is not carried with the process (.bar). But at least it should work.
Another big issue is that the URLs of the loaded resources are NO MORE processed by Bonita so that they can be found in the application’s resources !
If I load SlickGrid/slick.core.js in the application’s resources of the process:
=> works when it is in the a form’s template as Bonita replaces the paths by the exact one including the process Id.
=> DOES NOT work when it is in BonitaForm.html !
The whole JS library must be put under portal/, and the URL is something like “themeResource?theme=portal&location=SlickGrid/slick.core.js”.
Bonitasoft empowers development teams with Bonita, the open-source and extensible platform to solve the most demanding process automation use cases. The Bonita platform accelerates delivery of complex applications with clear separation between capabilities for visual programming and for coding. Bonita integrates with existing solutions, orchestrates heterogeneous systems, and provides deep visibility into processes across the organization.