title: set page on p:datatable
body: <p>I've a datatable in primefaces and I want, when I add a row in it, view the last page of the datatable.</p>
  
  <p>My .xhtml page is:</p>
  
  <pre><code>&lt;h:form id=...&gt;
  ...
  &lt;p:dataTable var="webTemplate" id="templateTable" widgetVar="tbl1"/&gt;
  ...
  &lt;/h:form&gt;
  
  &lt;h:form id=...&gt;
  ...
  &lt;p:inputText id="txt_description" value="#{templateController.templateDescription}" label="templateDescription"&gt;
                 &lt;f:validateLength for="txt_name" minimum="1"/&gt;
                 &lt;p:ajax event="change"
                       listener="#{calculatePageTable.setPageTableTemplate}"  onsuccess="setTabIndexTT()"/&gt;
                 &lt;/p:inputText&gt;
  ...
  &lt;/h:form&gt;
  &lt;script type="text/javascript"&gt;
        function setTabIndexTT(){
                      tbl1.getPaginator().setPage(#{calculatePageTable.pageTableTemplate});
                  }
        &lt;/script&gt;
  </code></pre>
  
  <p>bean:</p>
  
  <pre><code>@ManagedBean
  @SessionScoped
  public class CalculatePageTable {
  
     private int pageTableTemplate = 0;
     private int pageTableField = 0;
  
     public void setPageTableTemplate() {
  
        final DataTable d = (DataTable) FacesContext.getCurrentInstance().getViewRoot()
              .findComponent("form:templateTable");
        pageTableTemplate = d.getPageCount() - 1;
  
     }
  
     public int getPageTableTemplate() {
        return pageTableTemplate;
     }
  
     public void setPageTemplateField() {
  
        final DataTable d = (DataTable) FacesContext.getCurrentInstance().getViewRoot()
              .findComponent("detailsTable:webTemplateUpdateTable");
        pageTableField = (d.getPageCount() - 1);
     }
  
     public int getPageTableField() {
        return pageTableField;
     }
  
  }
  </code></pre>
  
  <p>But the js function setTabIndexTT() is never called by onsuccess ajax...</p>
  
  <p>How do I can set last page of my datatable when adding a row?</p>
  
  <p>Primefaces version is 3.1.1</p>