Get Arraylist .value on javascript expression constant

1
0
-1

Hey friends, im working with some JS library on my process and it works, for use my .js I added a HTML widget and wrote the javascript code.

The javascript code is on a constant expression, but it needs an arrayList to run, when I use a static arraylist like this, is working ok :

var numbers=[50,14,7,8];

but now i need to get that numbers of my Global process variable (ArrayList), i added some listWiget to try this:

document.getElementById("ListWidget").value ;

but it not works.

somebody knows how to get global ArrayList variable values on my Constant Expressión.

thanks in advance.

1 answer

1
+2
-1

Hi.

I don't think you can use directly your list in a Constant Expression. But you can use your list by using a script. This script will return your HTML/JS code.

For example, if my list is "processList", I can use this script :

return "<div>"+processList.toString()+"</div><script> var num = "+processList.toString()+";</script>";

Another example where I display my list in a html table :

String script = "<table><tr>";

for (int x : processList) {
        script += "<td>"+x+"</td>";
}

script += "</tr></table>";

return script;

Comments

Submitted by gerardo.rivera.ext on Thu, 04/30/2015 - 02:39

Hey @yannick.lombardi thanks for u answer, it works great .

But that I really need is to get the list value with javaScript using the widget list.value, I was trying to do this first with a simple text Field like this:

<script type="text/javascript">

          var value = document.getElementById("name").lastChild;

          alert(value.innerHTML);


 </script>

The textField Contains a default value : "Rene" But this don't works for me, the alert just say : undefined value, i did it in a alone .HTML and it works great, i dont know why I can take the value by the id TexField on my PageTemplate.

finally i use the option Use layout generate template to put directly the Script Code on the HTML code. If i create a static div like this :

<div id="name"><div><div>Rene</div></div></div>

the alert works OK, I use 3 div ** and **.lastChild cuase bonita create 3 this the Bonita WebForm running:

<div id="name" class="bonita_form_entry">
  <div class="bonita_form_vertical_panel"><div>
    <div class="bonita_form_text bonita_form_static_field_top" id="name">Rene
      </div> </div></div> </div>

I hope you can help me to get the value of this texField i really dont understand why it dont works.

Note : im not using the JavaScrip editor, cause when I use a .JS library it contains may reserved words that the validator don´t recognized it. Is for that I put the