title: JSF. Call backing bean method on every page load
body: <p>here is my situation in short.</p>
  
  <p>I have page with datatable and few buttons backed by bean. Bean should be initialized with some default properties. That properties can be changed depending on action.
  I started with RequestScoped bean and @PostConstruct annotated method. but it seems that datatable works well only with View(Session)scoped. Now my setup look like this:</p>
  
  <pre><code>@ManagedBean
  @ViewScoped
  public class ProductsTableBean implements Serializable {
  
      private LazyDataModel&lt;Products&gt; productsData;
      @Inject
      private ProductsFacade model;
  
  
      public void onPageLoad() {
         // here some defaults are set
         // ...
         System.err.println("onPageLoad called");
      }
  
      public void addRow() {
         // andhere some defaults redefined
         // ...
         System.err.println("addRow called");
      }
  
      ...
  </code></pre>
  
  <p>and snippet from jsf page:</p>
  
  <pre><code>    &lt;p:commandButton action="#{productsTableBean.addRow()}"
                       title="save"
                       update="@form" process="@form" &gt;
      &lt;/p:commandButton&gt;
      ...
      &lt;f:metadata&gt;
          &lt;f:event type="preRenderView" listener="#{productsTableBean.onPageLoad}"/&gt;
      &lt;/f:metadata&gt;
  </code></pre>
  
  <p>And here is the main problem arise in calling order, i have following output:</p>
  
  <pre><code>onPageLoad called
  addRow called
  onPageLoad called &lt;-- :(
  </code></pre>
  
  <p>But i want addRow to be the last action to be called, like this:</p>
  
  <pre><code>onPageLoad called
  addRow called
  </code></pre>
  
  <p>Any simple solution here ?</p>