title: Getting backing bean value with Javascript
body: <p><em>JSF 2.0, Mojarra 2.0.1, PrimeFaces 3.4.1</em></p>
  
  <p>There are similar questions but I need sth. else; javascript function has to wait for the backing bean method, which is filling the variable that wanted to be pulled from js function. What I want to say is:</p>
  
  <pre><code>&lt;p:commandLink action="#{statusBean.getStatuses}" oncomplete="afterLoad()"/&gt;
  </code></pre>
  
  <p>Assuming js function just getting the value and printing it to the screen.</p>
  
  <pre><code>function afterLoad() {    
      alert("#{statusBean.size}");
  }
  </code></pre>
  
  <p>And here is the birthday kid:</p>
  
  <pre><code>@ManagedBean
  @ViewScoped
  public class StatusBean {
      public int size=0;
      List&lt;Status&gt; panelList = new ArrayList&lt;Status&gt;();
      public void getStatuses() {
          this.panelList = fillList();
          this.size = panelList.size(); //Assuming 3
      }
      //getter and setters
  }
  </code></pre>
  
  <p>So function alerts the size as 0 which is the initial value of it, while we're expecting to see 3. </p>
  
  <p><strong>How it's working:</strong> If I add the <code>@PostConstruct</code> annotation to bean's head surely it gets the correct size, because bean is already constructed before the page load. But this means redundant processes, value just needed after the commandlink action. So how to postpone the js function? Any ideas?</p>