title: Calling JSF ManageBean after PageLoad using f:event postAddToView
body: <p>I am writing an app using JSF 2.0. </p>
  
  <p>For one of the page, there is a section of the page that takes a long time to display.</p>
  
  <p>To improve the  user experience, I am thinking to load the page first and then automatically do an Ajax call back to the JSF manage bean object once the page is loaded successfully after 1st load.</p>
  
  <p>I am thinking to use f:event with type postAddView. </p>
  
  <pre><code>&lt;h:outputText id="dummyId"&gt;
      &lt;f:event type="postAddToView" listener="#{mngBean.doSomething}" /&gt;
  &lt;/h:outputText&gt;
  </code></pre>
  
  <p>However it seems like <strong>f:event postAddToView</strong> is still being processed before the page is displayed for the first time.</p>
  
  <p>The other options that I have explore is to create a hidden button and get javascript to trigger it. It works however I am just wondering if there is a nice JSF component/event that can do this instead of using java script.</p>
  
  <p>Thanks for your help.</p>
  
  <pre><code>&lt;h:commandButton id="dmyButton" 
  </code></pre>
  
  <p>value="#{mngBean.getSomething}" 
   actionListener="#{mngBean.doSomething}" 
   style="display: none" 
   type="submit"></p>
  
  <p>Java Script</p>
  
  <pre><code>&lt;script language="JavaScript"&gt;
   $(document).ready(function() {
    if (document.getElementById('form:dmyButton').value == 'true') {
     document.getElementById('form:dmyButton').click();
    }
  
   });
  &lt;/script&gt;
  </code></pre>
  
  <p>Thanks for all your help in advance</p>