PrimeFaces dataTable: how to catch rows-per-page event?

前端 未结 4 1758
小蘑菇
小蘑菇 2021-01-05 07:03

I cretated a PrimeFaces dataTable:



        
4条回答
  •  不思量自难忘°
    2021-01-05 07:58

    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.

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题