DataTable Selection + Pagination Issue

UI Components for JSF
Post Reply
Karan
Posts: 1
Joined: 23 Jun 2011, 15:38

23 Jun 2011, 16:38

PrimeFaces 3.0.M2 (latest snapshot).
Mojarra 2.1.2
Tomcat 7

Issue: When selection & pagination is enabled on a data table, pagination doesn't work after one or more rows are selected.

Can be reproduced at the PrimeFaces 3.0 Showcase
http://www.primefaces.org/showcase-labs ... eckbox.jsf

Select one or more rows on the page and try the pagination controls. Though the control shows that it moved to the next page, the data remains the same.

Reason:

Code: Select all

 public boolean isPaginationRequest(FacesContext context) {
        if(pageRequest == null) {
            Map<String,String> params = context.getExternalContext().getRequestParameterMap();

            pageRequest = params.containsKey(this.getClientId(context) + "_paging"); // ISSUE - returns FALSE when it's actually TRUE
        }

        return pageRequest;
    }
The getClientId() appends the rowIndex (as there is at least one row selected) to the client Id, so it's unable to retrieve the _paging param and returns FALSE always.

Suggested Fix: (It's only been a week since I started using PrimeFaces, so this fix might not be the right one, but they fixed the problem I encountered).

Similar to few other methods on the DataTable, setting the Row Index to -1 before retrieving the client ID and paging param solves this issue.

Code: Select all

    public boolean isPaginationRequest(FacesContext context) {
        if(pageRequest == null) {
        	int rowIndex = this.getRowIndex();  
        	this.setRowIndex(-1); // FIX
        	
            Map<String,String> params = context.getExternalContext().getRequestParameterMap();

            pageRequest = params.containsKey(this.getClientId(context) + "_paging");
            this.setRowIndex(rowIndex);
        }

        return pageRequest;
    }
I reset the RowIndex back to it's original value as I wasn't sure if it is needed elsewhere.

Edit: Should I create a new Issue for this?[*]

- Karan

gysh
Posts: 1
Joined: 24 Jun 2011, 10:38

24 Jun 2011, 10:52

This bug can also be reproduced in the lazy loading example:
http://www.primefaces.org/showcase-labs ... leLazy.jsf

The pagination is completely broken after row selection.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 34 guests