0

I've got a primefaces datatable with some data generated, with multiple selection and pagination and i have to count all the selected rows on each page and i done this but the problem is that i have to count also the number of subpages with selected items on it. So if i check 3 items on page number 1 and 3 items on page number 3 i want an output like: selected: 6 subpages: 2. Is there an easy way to count subpages ? For counting rows i just use a lenght of selected items table. How can i do this ?

Gravian
  • 957
  • 2
  • 11
  • 20
  • You know how much rows is showing per page, I guess you could do a loop to your list checking the selected item and position in the list, and increment the subpage (count) number. Just be careful with the number of item_selected in the same page. – danRod Aug 09 '13 at 19:01
  • That was the first thing that came to my mind and i'll propably do this that way but i was hoping that there is some other easy way. Thanks anyway. – Gravian Aug 10 '13 at 16:47

1 Answers1

0

You could use a listener in the bean to get current page onselection and kept a tally.

 EX.
 DataTable dataTable = (DataTable) FacesContext.getCurrentInstance().getViewRoot()
            .findComponent("someOformID:someTableId");
    dataTable.getPage()
Justin Cox
  • 326
  • 4
  • 22
  • i dont need the current selected page, but i need the number of pages with selected items. – Gravian Aug 10 '13 at 16:42
  • if you have an action on select, you will know each time this action is fired, therefore you will know which pages have selected items. Other logic could fail if the rows per page ever changed. – Justin Cox Aug 12 '13 at 11:44