Primefaces: set page on datatable

来源:互联网 发布:单片机浇花系统 编辑:程序博客网 时间:2024/06/05 15:00

In your managed bean you can try this code:

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

Call this method when you add a new row

0 0