Pergunta

Goal: I'd like to reset the pagination to page 1 when a user does a new search.

Code:

search.xhtml

<rich:datatable id=searchResultsTable value=#{SearchAction.searchResults}"
                render="scroller" first="#{SearchAction.firstRecord}">
    <!-- columns here -->
</rich:datatable>

<rich:dataScroller id="scroller" page = "#{SearchAction.currentPage}" for="searchResultsTable"/>

Search panel:

<!-- headers and other stuff -->
<h:commandButton actionListener="#{SearchAction.resetPage}" 
                 action="#{SearchAction.performSearch}" />

SearchAction:

private int currentPage;
private int firstResult;

public void performSearch()
    {
    //do search stuff
    }

public void resetPage()
    {
    setCurrentPage( 1 );
    setFirstResult( 0 );
    }

//Getters and Setters

Current Behavior: Search, go to page 2, page 2 shows up. Do new search, page number says one, but table shows page 2's data. (Limiting rows per page to 20 and total rows to 25, so it's easy to tell)

Expected Behavior: Should reset page to 1, and show the first result.

From what I've read, this worked in Richfaces 3.3, but it doesn't seam to work as expected in 4.2. Any help that can be provided would be much appreciated.

Foi útil?

Solução

Found a work around using the first API. Kind of annoying that it displays the first page of results, and then rerenders the new results, but it's better than not working.

searchPanel.xhtml

<a:commandButton action="#{SearchAction.performSearch()}" 
                 onbegin="#{rich:component('waitPanel')}.show()"
                 onbeforedomupdate="#{rich:component('waitPanel')}.hide()"
                 onclick="#{rich:component('scroller')}.first()
                 render=searchResultsTable scroller"/>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top