0
I have to call a function in my JS by passing as parameter an array, when the page is loaded.
I can do it using one p:commandButton, where here: actionListener="#{rotaEntregaBean.gerarMapa()}" i run the function in the Bean (taking values in the database) and then, aqui:oncomplete="initMap(xhr, status, args)" i run the JS function.
Knob
<p:commandButton id="btnMapa" value="Gerar Rota" icon="ui-icon-pin-s" 
 actionListener="#{rotaEntregaBean.gerarMapa()}"
 style="float:right" oncomplete="initMap(xhr, status, args)"/> 
Bean
But I’m willing to do it without having to click the button, once I load the page.
In my page I already start a Bean method as shown in the image below, but I don’t know how to call the JS function with parameter.
Calling Bean method as soon as the page is loaded:
<f:metadata>  
    <o:viewParam name="entrega_id" value="#{rotaEntregaBean.id_entrega}" />
    <f:viewAction action="#{rotaEntregaBean.inicializar}" />
</f:metadata>
JS function
function initMap(xhr, status, args) {   
    var qtd_entregas = args.coord.length;
    for (var i = 0; i < args.coord.length; i++) {
        waypts.push({
            location : args.coord[i].latitude + ', ' + args.coord[i].longitude,
            stopover : true,
        });
    }
...
}
						
I tried this way, but as I will pass the vector by parameter to the JS function I am calling?
– Bruno Enes