title: passing java variable to javascript function
body: <p>I will need to pass a java variable to a javascript function. I have my codes as below. Wondering is that the correct way?</p>
  
  <p>Because I have some problem here when the page first load, and the button is clicked, the chartData and categories is empty. </p>
  
  <p>I am expecting the below:</p>
  
  <pre><code>chartData = [{"name":"Anne","data":[1.0,0.0,4.0]},
               {"name":"Billy","data":[5.0,7.0,10000.0]}]
  categories = ["APPLES","BANANAS","ORANGES"]
  
  public String doLoadChartDataAction () {
  
      String _cat = "[{\"name\":\"Anne\",\"data\":[1.0,0.0,4.0]},{\"name\":\"Billy\",\"data\":[5.0,7.0,10000.0]}]";
      String _data = "[\"APPLES\",\"BANANAS\",\"ORANGES\"]";
  
      System.out.println("1.0 " + " _cat:" + _cat);
      System.out.println("1.0 " + " _data:" + _data);
  
      setCategories(_cat);
      setChartData(_data);
  
      return "";      
  }
  
  
   &lt;p:commandButton styleClass="commandButton" value="This" id="btnThis" action="#{pc_Test.doLoadChartDataAction}" 
      oncomplete="renderChart('container','line','Sample Chart','${pc_Test.chartData}', '${pc_Test.categories}');"&gt;   
   &lt;/p:commandButton&gt;
  </code></pre>