I cretated a PrimeFaces dataTable:
-
A simpler way that what is written above (tested with Primefaces 7.X) is to simply use the accessors method. This solution has the advantage to have the actual number of row being set. Otherwise, in my case I would obtain the previous number of row, before it is changed ...
.....
.....
And the bean should simply look like :
@ViewScoped
@Named
public class Controller implements Serializable {
private int rowsPerPage = 25; //default value
public int getRowsPerPage() {
return rowsPerPage;
}
/** Will be called each time the number or selected rows change */
public void setRowsPerPage(int rows){
this.rowsPerPage = rows;
// Do some other stuff, like using a cache to store the value
}
}
I personally use a cache storing the number of rows per user and entity types.
- 热议问题