Making a data filter

Asked

Viewed 116 times

1

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

Follow the code that has been 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 insert something into the field, press the button, nothing happens to the table... It is not updated.

Could someone help me?

  • Which table? I don’t think there is any table code in that xhtml, or am I mistaken.

  • Is that a datatable? If so, post the full xhtml.

  • @Gustavocinque When I spoke table, I was referring to one of the database...

  • @Douglas ready

  • Hold on, buddy boy. we do not have the Submit button and we do not have the method of insertion in the database, as you want us to know that it is a problem in insertion?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.