I want to pass a list of objects (list_A in the example), in a jsf file, to a function in javascript. The problem is that the call event.name="#{controllerManagedBean.list_A.get(y).getName()}"; assigns to event.name the value as if the "y" always had a value of 0, that is, the first item in the list.
How can I go through the list and pass all the names to list_1 (without a json, if possible)?
Thanks!!
Here is my code (the important thing is the script, I think):
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
        <script src="visJS/dist/vis.js"></script>
        <link href="visJS/dist/vis-timeline-graph2d.min.css" rel="stylesheet" type="text/css" />
    </h:head>
    <h:body>
        <h:form>
            <h:dataTable value="#{controllerManagedBean.list_A}"
            var="evento" border="2"
            cellspacing="1" cellpadding="1">
                <h:column>
                    <f:facet name="header">Evento</f:facet>
                    #{evento.nombre}
                </h:column>
            </h:dataTable>
        </h:form>
        <div id="timeline">Prueba</div>
        <script src="js/timeline.js"></script>
        <script>
          var x = parseInt('#{controllerManagedBean.list_A.size()}');
          var list_1 = new Array();
          //<![CDATA[
              for(var y = 0; y<x; y++){
          //]]>
                  var evento = new Object();
                      evento.nombre = "#{controllerManagedBean.list_A.get(y).getNombre()}";
                      list_1.push(evento);
              }
          myFunction(list_1);
        </script>
    </h:body>
</html>