2 Replies Latest reply on Aug 25, 2010 10:47 AM by Well Nery

    Loop in javascript code with EL expression

    Well Nery Newbie

      Hi everybody,

      I wanna make something like this in my XHTML file:



            <a4j:jsFunction id="fill" name="fill">
                     <a4j:repeat id="repeatCar" value="#{bean.list}" var="var" rowKeyVar="row">
                         array["#{row}"] = "#{var.myAttribute}";
      I did declare array variable as global in javascript scope. This function only work when page render  the first time, when I call this function by name it don't work, because this piece of code generate this:
      <script id="formId:j_id50" type="text/javascript">
      array["0"] = "12";
      array["1"] = "123";
      array["2"] = "1234";
      So I tried make a loop in javascript code:
      function test () {
             for(i = 0; i < array.length; i++) {
                 array[i] = "#{bean.list["+i+"].myAttribute}";
      But don't work!!
      I really need make a loop in javascript code because I'm using a javascript library called OpenLayers and the coordinates (in array variable) need be passed and updated by javascript code !! Have any way or any idea to perform this?
      Thank's a lot!