Вопрос по java, jsf-2, primefaces, ajax – Primefaces: установить страницу данных

12

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

<h:form id=...>
...
<p:dataTable var="webTemplate" id="templateTable" widgetVar="tbl1"/>
...
</h:form>

<h:form id=...>
...
<p:inputText id="txt_description" value="#{templateController.templateDescription}" label="templateDescription">
               <f:validateLength for="txt_name" minimum="1"/>
               <p:ajax event="change"
                     listener="#{calculatePageTable.setPageTableTemplate}"  onsuccess="setTabIndexTT()"/>
               </p:inputText>
...
</h:form>
<script type="text/javascript">
      function setTabIndexTT(){
                    tbl1.getPaginator().setPage(#{calculatePageTable.pageTableTemplate});
                }
      </script>

Error: User Rate Limit Exceeded

@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;
   }

}

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Ваш Ответ

4   ответа
6

<script type="text/javascript">
            $(document).ready(function () {
                dataTableWidget.paginator.setPage(0);
            });
 </script>
Error: User Rate Limit Exceededstackoverflow.com/a/33413948/1599699 PF('dataTableWV').paginator.setPage(PF('dataTableWV').paginator.cfg.pageCount - 1); RequestContext.getCurrentInstance().execute("PF('dataTableWV').paginator.setPage(PF('dataTableWV').paginator.cfg.pageCount - 1);");
2

first

<p:dataTable first="#{calculatePageTable.first}"/>
...
<p:commandButton value="Add a row" action="#{calculatePageTable.addRow}"/>

public class CalculatePageTable {
    private int first = 1;

    public int getFirst(){
        return first;
    }

    public void addRow(){
        // 1. your stuff for adding the row 
        ...
        // 2. switch to the row
        first = getFirstRowOnLastPage(); 
    }

    private int getFirstRowOnLastPage(){
        ...
    }
}
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded 3vi
Error: User Rate Limit Exceeded 3vi
Error: User Rate Limit ExceededaddRowError: User Rate Limit ExceededaddRowError: User Rate Limit Exceeded
Error: User Rate Limit Exceeded 3vi
12

public void setPageDataTable() {
    final DataTable d = (DataTable) FacesContext.getCurrentInstance().getViewRoot()
        .findComponent("form:templateTable");
    int first = 1;
    if (d.getRowCount() % ROWS_DATATABLE == 0) {
        first = (d.getRowCount() - ROWS_DATATABLE);
    }
    else 
    {
        first = (d.getRowCount()/ROWS_DATATABLE)*ROWS_DATATABLE;
    }
    d.setFirst(first);
}

Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceededd.setFirst(first);Error: User Rate Limit Exceeded((DataTable) FacesContext.getCurrentInstance().getViewRoot().findComponent("myForm").findComponent("myDataTable")).setFirst(0)Error: User Rate Limit Exceeded
Error: User Rate Limit ExceededROWS_DATATABLEError: User Rate Limit Exceeded
0

<p:dataTable var="webTemplate" id="templateTable" widgetVar="tbl1" binding="#{calculatePageTable.dataTable" />

public class CalculatePageTable {
private DataTable dataTable;

public DataTable getDataTable() {
    return dataTable;
}

public void setDataTable(DataTable dataTable) {
    this.dataTable = dataTable;
}

/* See Teg's answer */
public void setPageDataTable() {
    int first = 1;
    if (dataTable.getRowCount() % ROWS_DATATABLE == 0) {
        first = (dataTable.getRowCount() - ROWS_DATATABLE);
    }
    else 
    {
        first = (dataTable.getRowCount()/ROWS_DATATABLE)*ROWS_DATATABLE;
    }
    dataTable.setFirst(first);
}
}
Error: User Rate Limit Exceededstackoverflow.com/questions/8392236/…

Похожие вопросы