DataTable Bug

UI Components for JSF
Post Reply
Alexandre Ferreira
Posts: 3
Joined: 21 Oct 2010, 16:37

21 Oct 2010, 17:07

Hi,

I'm trying to use PrimeFaces in my app, and I have a trouble.

I'm using <p: dataTable> in a result page of a search, with 10 records for page. The search returns 100 itens, wich represents 10 pages. If I navigate to page 8, for example and perform the search again, the page supposed to be presented is the first, but the page 8 is still presented.

I wanted to know how to erase the page counter when I make a new search.

Could you help me?


Alexandre Ferreira
Posts: 3
Joined: 21 Oct 2010, 16:37

21 Oct 2010, 20:19

Thank Youuuuu !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

:D :D :D :D :D :D

Code: Select all

            dataModelTransacao = new LazyDataModel<Transacao>(){

                private static final long serialVersionUID = 5728620055891308704L;

                @Override
                public List<Transacao> load(int inicio, int quantidade, String sortField, boolean sortOrder, Map<String, String> filters) {
                    System.out.println(" Carregando registros no intervalo de " + inicio + " até " + (inicio + quantidade));
                    List<Transacao> pesquisaTransacao = transacaoService.buscaPorFiltros(funcionario, dataInicio, dataFim, quantidade, inicio);
                    if(pesquisaTransacao != null && !pesquisaTransacao.isEmpty()){
                        return pesquisaTransacao;
                    }
                    return new ArrayList<Transacao>();
                }
            };
            Long count = transacaoService.countPorFiltros(funcionario, dataInicio, dataFim);
            dataModelTransacao.setRowCount(count.intValue());

            List<Transacao> pesquisaTransacao = transacaoService.buscaPorFiltros(funcionario, dataInicio, dataFim, 10, 0);
            dataModelTransacao.setWrappedData(pesquisaTransacao);

            DataTable dt = (DataTable) FacesContext.getCurrentInstance().getViewRoot().findComponent("consultaForm:transacaoDataTable");
            dt.setPage(1);

callahan
Posts: 768
Joined: 27 May 2010, 22:52

21 Oct 2010, 20:24

No problem. Happy PrimeFacing ;).

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 33 guests