0
votes

I have a richfaces extendeddatatable with a datascroller. We wrote an own class which extends the ExtendeddataModel.

Everything is working fine until the following scenario:

  1. Go to the last page of the datascroller
  2. Use any filter that leads to a smaller amount of data, so the last page does not exist any more

Result: the datascroller "jumps" to the right page, but datatable is still displayed empty

After some debugging I found out that the "walk()" method of the ExtendeddataModel-Implementation is called BEFORE the datascroller writes into the log:

The requested page isn't found in the model. Paging  is reset to page... 

We use filtering, sorting, a push mechanism for new data... so a kind of complex environment which I can't really post here, but I try to point out the most important parts.

<h:selectManyCheckbox value=#{controller.filter}>
    <f:selectItems value="#{controller.filterOptions} />
    <a4j:ajax render="table scroller" />
</h:selectManyCheckbox

<rich:extendeddatatable id="table" ... />

<rich:dataScroller for="table" id="scroller" renderIfSinglePage="false" 
    page="#{controller.page}"

Adding render="table" to the datascroller did not help. The only thing that helped was putting the rendering into two different requests, so first only datascroller is rendered and after this the datatable.

Is there a way to do this without 2 requests? Am I able to force a rendering order? Or do I simply miss something in the configuration of the dataScroller/ datatable, to render it after the scroller was reset...

1

1 Answers

0
votes

I was able to fix this issue by resetting the page manually in the java code.

In detail I change the walk(...) method of the Extendeddatamodel like this:

@Override
public void walk(FacesContext context, DataVisitor visitor, 
    Range range, Object argument){

    SequenceRange sequenceRange = (SequenceRange) range;

    int firstRow = sequenceRage.getFirstRow();
    int rows = myDB.getCount();

    if(firstRow > rows){
        int fullPages = rows / ROWS_PER_PAGE;
        int rest = rows % ROWS_PER_PAGE;

        if(rest == 0){
            firstRow = rows - ROWS_PER_PAGE;
            this.setPage(fullPages);
        }else{
            firstRow = rows - rest;
            this.setPage(fullPages + 1);
        }
    }

...
 // visitor.process(...); stuff
...

 }

I still belive that exactly this stuff normaly the datascroller itself should do, but at least my current problem is solved.