Making a data filter

1

I have a page where I get data from a table in my database. In it, a field and a form, to filter data from the table.

The following code is used to make the filter:

<p:panel header="#{language['tela.cadastro.pedido.filtro']}" rendered="#{reprogramarPedidoBean.data!=null}">

                        <h:panelGrid id="gridPesquisa1" columns="2" rows="1">
                            <h:outputText value="#{language['coluna.numeroPedido']}:" for="numeroPedidoPesquisa" style="font-weight: bold;" />
                            <p:inputText id="numeroPedidoPesquisa" value="#{reprogramarPedidoBean.numeroPedido}" />

                            <h:outputText value="#{language['tela.cadastroCliente.codigo']}:" for="codigoClientePesquisa" style="font-weight: bold;" />
                            <p:inputText id="codigoClientePesquisa" value="#{reprogramarPedidoBean.codigoCliente}" />

                        </h:panelGrid>

                        <h:panelGrid id="gridPesquisa2" columns="2" >
                            <p:commandButton id="pesquisarButtons" value="#{language['label.pesquisar']}"
                                action="#{reprogramarPedidoBean.search('tabela')}" update="tabela msgGeral" global="true"/>
                        </h:panelGrid>


                    </p:panel>

And the method called:

public void search(String idDataTable) {

        List<Pedido> l = new ArrayList<Pedido>();
        if (numeroPedido.isEmpty() && codigoCliente.isEmpty() && data != null) {
            buscarPedidos();
        } else {
            for (Pedido p : listaPedidos) {

                if (numeroPedido != null && !numeroPedido.isEmpty()) {
                    if (p.getNumero().equals(numeroPedido) && !l.contains(p)) {
                        l.add(p);
                    }
                }
                if (codigoCliente != null && !codigoCliente.isEmpty()) {
                    if (p.getCliente().getCodigoCliente().equals(codigoCliente)
                            && !l.contains(p)) {
                        l.add(p);
                    }
                }

            }
            listaOrdens.clear();
            for (Pedido p : l) {
                listaOrdens.addAll(p.getListaOrdens());
            }
        }

    }

Datatable:

<h:panelGroup id="pedidoPanel" >
                        <p:dataTable id="tabela" var="pedido" value="#{reprogramarPedidoBean.listaPedidos}" paginator="true" rows="20"
                            emptyMessage="#{language['mensagem.nenhumRegistro']}" currentPageReportTemplate="({currentPage} de {totalPages})"
                            paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                            rowKey="#{pedido.id}" lazy="true">
                            <p:column exportable="false">
                                <p:rowToggler />
                            </p:column>

                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="#{language['coluna.data']}" />
                                </f:facet>
                                <h:outputText value="#{pedido.data}">
                                    <f:convertDateTime pattern="dd/MM/yyyy" />
                                </h:outputText>
                            </p:column>

                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="#{language['coluna.numeroPedido']}" />
                                </f:facet>
                                <h:outputText value="#{pedido.numero}" />
                            </p:column>

                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="#{language['coluna.codigoCliente']}" />
                                </f:facet>
                                <h:outputText value="#{pedido.cliente.codigoCliente}" />
                            </p:column>

                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="#{language['coluna.pesoTotal']}" />
                                </f:facet>
                                <h:outputText value="#{pedido.pesoTotal}" />
                            </p:column>

                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="#{language['coluna.volumeTotal']}" />
                                </f:facet>
                                <h:outputText value="#{pedido.volumeTotal}" />
                            </p:column>     

                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="#{language['coluna.cubagemTotal']}" />
                                </f:facet>
                                <h:outputText value="#{pedido.cubagemTotal}" />
                            </p:column>                 

                            <p:column style="text-align: center;">
                                <f:facet name="header">
                                    <h:outputText value="#{language['coluna.liberado']}" />
                                </f:facet>
                                <h:outputText value="#{(pedido.liberado)?language['reprogramarPedido.html.pedido.liberado.sim']:language['reprogramarPedido.html.pedido.liberado.nao']}" />
                            </p:column>
                            <p:column id="reprogramarColuna" style="text-align: center;">
                                <f:facet name="header">
                                    <h:outputText value="#{language['tela.reprogramarPedido.header2']}" style="text-align: left;" />
                                    <p:selectBooleanCheckbox value="#{reprogramarPedidoBean.todosPedidosSelecionado}" style="text-align: center;">
                                        <p:ajax update="tabela" listener="#{reprogramarPedidoBean.processaCheckAll()}" />
                                    </p:selectBooleanCheckbox>
                                </f:facet>
                                <p:selectBooleanCheckbox value="#{pedido.selecionado}" style="text-align: center;">
                                        <p:ajax update="tabela" listener="#{reprogramarPedidoBean.processaCheckPedido(pedido)}" />
                                </p:selectBooleanCheckbox>
                            </p:column>                         
                        </p:dataTable> 
                    </h:panelGroup>

PS: They bring me the filtered data

However, when I enter something in the field, I press the button, nothing happens to the table ... It is not updated.

Could anyone help me?

    
asked by anonymous 17.10.2016 / 18:39

0 answers