Html-widget-groovy-javascript-increase counter-variable

1
0
-1

Hellooooooo,

Could anyone give me an example in:

How could i increase a counter in Bonita 5.9 in html widget??? I have define a counter as global-variable in Bonita Studio and i have a problem to increase the counter-variable. The main reason of that is , in Groovy Editor,(which i write code) , is not supported to write html-code or javascript without these symbols----> " "

What is that i make a mistake? For example:

" "+ "

"+
"<body>"+
"<p id='demo'></p>"+
"<script>"+
"var tmp="+(counter+1) +";"+     //COUNTER: IS GLOBAL VARIABBLE IN BONITA STUDIO
"var x='<table>';"+
"x=x+'<tr><th>ΑΡΙΘΜΟΣ ΑΙΤΗΣΗΣ</th><th>ΤΡΑΠΕΖΑ</th><th>  ΗΜΕΡΟΜΗΝΙΑ  </th><th>     ΚΑΤΑΣΤΑΣΗ        </th></tr><tr>';"+
"for (var i=0; i<5;i++){"+
"var adder='"+counter+"';"+            //IN THESE STEP,I WOULD LIKE TO INCREASE THE VARIABLE COUNTER,EVERY TIME TO RUN THE FOR-LOOP-.HOW CAN DO IT?
"  x=x+'<tr>
';"+
"  x=x +'<td>'+ 'The number of application ' +adder + '</td>';"+
" x=x +'<td>'+ 'The Status is  ' + tmp +'</td>';"+
"  x=x+'</tr>';"+
"  }"+
"x=x+'</table>';"+
"document.getElementById('demo').innerHTML = x;"+
"</script>"+
"</body>"+
"

"

2 answers

1
0
-1

Hi,

Here is a working example using the code provided above: http://we.tl/PFmQfFgm0Z

Cheers, Francois

Comments

Submitted by Multix on Thu, 05/08/2014 - 15:03

Firstly,Thank u a lot for your answer!! :)) Could you to resend the example??But the type of the file is *.proc OR *.bar OR *.bpmn??? As MyDiagram2-1.0.bos ,i cannot opened it!!!

Thank again in advance Katerina

Submitted by francois.chevresson on Thu, 05/08/2014 - 15:12

Hi,

Sorry, I forgot you were on 5.X. My export comes for a Studio 6.2 I don't have a 5.x installed on my machine currently, but it will be the same exact groovy code. In your html widget, just copy this:

"<p id='demo'></p>"+
"<script>"+
"var tmp="+(counter+1) +";"+ //COUNTER: IS GLOBAL VARIABBLE IN BONITA STUDIO
"var x='<table>';"+
"x=x+'<tr><th>ΑΡΙΘΜΟΣ ΑΙΤΗΣΗΣ</th><th>ΤΡΑΠΕΖΑ</th><th> ΗΜΕΡΟΜΗΝΙΑ </th><th> ΚΑΤΑΣΤΑΣΗ </th></tr><tr>';"+
"for (var i=0; i<5;i++){"+
"var adder='"+counter+"';"+ //IN THESE STEP,I WOULD LIKE TO INCREASE THE VARIABLE COUNTER,EVERY TIME TO RUN THE FOR-LOOP-.HOW CAN DO IT?
" x=x+'<tr>';"+
" x=x +'<td>'+ 'The number of application ' +adder + '</td>';"+
" x=x +'<td>'+ 'The Status is ' + tmp +'</td>';"+
" x=x+'</tr>';"+
" }"+
"x=x+'</table>';"+
"document.getElementById('demo').innerHTML = x;"+
"</script>"
- See more at: http://community.bonitasoft.com/answers/html-widget-groovy-javascript-increase-counter-variable#node-14304

Cheers, Francois

Submitted by ttoine on Wed, 05/14/2014 - 12:21

François, did you created the example process with a Subscription version ?

Submitted by francois.chevresson on Wed, 05/14/2014 - 13:14

Yes I did, but there is nothing specific to SP version in the groovy script provided.

1
0
-1

Hi,

Your HTML widget will be render in the Bonita form body tag already. You should try to remove: "

"+ and "

</body>

"+

Cheers, Francois

Comments

Submitted by Multix on Fri, 05/02/2014 - 09:22

Yes,but without ""+ and ",the editor is appeared error. Could you give an example that appeared a list of name in a table?

Thank in advance

Submitted by francois.chevresson on Mon, 05/05/2014 - 21:11

I have update my previous comment. It was not showing properly earlier.

This is the update code:

"<p id='demo'></p>"+
"<script>"+
"var tmp="+(counter+1) +";"+ //COUNTER: IS GLOBAL VARIABBLE IN BONITA STUDIO
"var x='<table>';"+
"x=x+'<tr><th>ΑΡΙΘΜΟΣ ΑΙΤΗΣΗΣ</th><th>ΤΡΑΠΕΖΑ</th><th> ΗΜΕΡΟΜΗΝΙΑ </th><th> ΚΑΤΑΣΤΑΣΗ </th></tr><tr>';"+
"for (var i=0; i<5;i++){"+
"var adder='"+counter+"';"+ //IN THESE STEP,I WOULD LIKE TO INCREASE THE VARIABLE COUNTER,EVERY TIME TO RUN THE FOR-LOOP-.HOW CAN DO IT?
" x=x+'<tr>';"+
" x=x +'<td>'+ 'The number of application ' +adder + '</td>';"+
" x=x +'<td>'+ 'The Status is ' + tmp +'</td>';"+
" x=x+'</tr>';"+
" }"+
"x=x+'</table>';"+
"document.getElementById('demo').innerHTML = x;"+
"</script>"

Not sure it is what you are trying to achieve ultimately but at leat the code executes and the table is rendered.

Cheers, Francois

Notifications