javascript file load and widget script load concurrency

1
0
-1

Bonitasoft 6.4.1. When using several customized javascripts files used by a widget, the widget is sometimes loaded and executed before the javascript it requires (using $( document ).ready() doesn t solve the problem), thus yielding to unrecognized variables. Easily reproducible by using about 10 javascripts of about 50 kb, and observing the load (using breakpoint) in firefox or chrome browser. Note that i actually do not use so many javascript, and i do use minify, but the problem is easily reproducible with that configuration; with less javascript it just happens less often. As a posible cause, is bonitasoft using dynamical javascript load (see http://community.bonitasoft.com/answers/javascript-file-load ) ?

1 answer

1
0
-1
This one is the BEST answer!

Hi,

I think my message here should answer your question.

Comments

Submitted by nsaintaubert on Wed, 01/28/2015 - 16:31

@anthony.birembaut, That explains the whole thing, thanks.

Submitted by nsaintaubert on Wed, 01/28/2015 - 16:47

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.

Submitted by anthony.birembaut on Wed, 01/28/2015 - 17:33

Yes, we are aware of that. We are currently working on a new form builder in which those issues (among others) should be addressed.

Submitted by Sean McP on Thu, 01/29/2015 - 06:18

@anthony.birembaut - I never really thought this was a problem until I experienced it this morning.

And this is a real problem for me now, I cannot guarantee my processes will continue working without resorting to some dreadful coding.

In my case I have a number of checkboxes, and one check box to rule them all as follows:

CB Select All
CB Board
CB CEO
CB CFO
CB CIO
etc.

I have javascript attached to CB Select All that toggles the rest as necessary if not making individual selections.

But now I can't do this as the IDs for all the CB's have changed from the previous version. No longer starting at 1 but in my case 3, 5, 6, 9 etc.

We need a better way of being able to attach our javascript to our HTML DOM elements.

Actually a question, why not use the "user defined widget name" from Studio rather than the generated code (gwt-uid-3) and for iterative items use "user defined widget name"+Index starting at 0 (zero)

This would work all the time. I mean we are forced to give each widget a unique name, why use your names instead of ours?

As it is my work around code will have to be:

getElementsByTagName(CB)
for each(){
if name = "Select All"{
    attach event;
    break;
    }
}

I think you'll agree, I shouldn't have to do that.

many thanks and best regards Seán

PS You mention the new form builder that should address some of these issues. Can I ask when? 6.4.2 or 6.5? I ask because I have all this bad code to make sure works for every version in-between now.

Submitted by anthony.birembaut on Thu, 01/29/2015 - 16:01

Hi, Actually, we do use the "user defined widget name". It is used as the id of the container for the whole widget (input + label). So instead of using the checkbox id (which is indeed generated by GWT) you can do something like:

checkboxContainer = document.getElementById("yourWidgetNameDefinedInTheStudio");
checkbox = checkboxContainer.getElementsByTagName("input")[0];
checkbox.checked = true;

Regarding the new form builder, it is not for 6.4.2 (which is a maintenance version) nor 6.5. It is more long haul.

Submitted by Sean McP on Fri, 01/30/2015 - 04:27

@anthony.birembaut, thanks for that, yes I see it now. Shows I'm not that good at JavaScript. You learn something everyday.

regards Seán

Submitted by tonytong198 on Mon, 12/07/2015 - 09:43

Easily reproducible by using about 10 javascripts of about 50 kb, and observing the load (using breakpoint) in firefox or chrome browser. Note that i actually do not use so many javascript minify http://www.online-code.net/minify-js.html , but the problem is easily reproducible with that configuration; with less javascript it just happens less often. As a posible cause, is bonitasoft using dynamical javascript load

I have the same issue, I want to combine all the js file, and compress it to reduce the total html size.

Notifications