LazyDaModel with PrimeFaces DataTable

0

Personal I have an application developed in Java with primeFaces, Hibernate and MySql database. I developed a method to update my dataTable page by page (Lazy loading). It is a page of Nota Fiscal that loads in the rowExpendive the items of the Note. The problem is when I try to click on a note to edit it. is presenting the error. Caused by: java.lang.UnsupportedOperationException: getRowData (String rowKey) should be implemented when basic rowKey algorithm is not used.

I do not know where to implement this method. Can anybody help me.: Below is the tableTable and the method that loads the note data.

                            <p:dataTable paginator="true" rows="08" draggableColumns="true"
                            value="#{notaFiscalBean.notas}" var="nota"
                            selectionMode="single" selection="#{notaFiscalBean.notaFiscal}"
                            reflow="true" scrollable="true" lazy="true"
                            emptyMessage="Nenhum Registro Encontrado."
                            widgetVar="listNotaFiscal" rowKey="#{nota.codigo}"
                            paginatorPosition="bottom">
                            <p:ajax event="rowSelect" listener="#{notaFiscalBean.editar}" update=":formCadastro:painel :mensagem" onclick="PF('entradaDeNotaFiscal').show();" />

                            <f:facet name="header">
                                <p:commandButton title="Novo" icon="fa fa-plus"
                                    onclick="PF('entradaDeNotaFiscal').show()"
                                    actionListener="#{notaFiscalBean.novo}"
                                    update=":formCadastro:painel :mensagem" />

                                <p:commandButton title="Editar" icon="fa fa-fw fa-edit"
                                    actionListener="#{notaFiscalBean.editar}"
                                    onclick="PF('entradaDeNotaFiscal').show();"
                                    update=":formCadastro:painel :mensagem" />

                                <p:commandButton title="Voltar" icon="fa fa-mail-reply" />
                            </f:facet>

                            <p:column style="width: 15px">
                                <p:rowToggler/>
                            </p:column>

                        <p:rowExpansion>
                                <p:dataTable reflow="true" rows="10" draggableColumns="true"
                                    value="#{nota.itensDaNotaFiscal}" var="itemDaNota" 
                                    style="width: 98%" emptyMessage="Nenhum Registro Encontrado."
                                    paginator="true" paginatorPosition="bottom">

                                    <p:column headerText="Cod." style="width: 40px">
                                        <h:outputText value="#{itemDaNota.produto.codigo}" />
                                    </p:column>

                                    <p:column headerText="Descr. Produto" style="width: 400px">
                                        <h:outputText value="#{itemDaNota.produto.descricao}" />
                                    </p:column>

                                    <p:column headerText="Quant."
                                        style="width: 100px; text-align: center">
                                        <h:outputText value="#{itemDaNota.quantidade}">
                                            <f:convertNumber minFractionDigits="3" locale="pt_BR" />
                                        </h:outputText>
                                    </p:column>

                                    <p:column headerText="Vlr. Unit."
                                        style="width: 100px; text-align: right">
                                        <h:outputText value="#{itemDaNota.valorUnitario}">
                                            <f:convertNumber locale="pt_BR" minFractionDigits="3" />
                                        </h:outputText>
                                    </p:column>

                                    <p:column headerText="Vlr. Total"
                                        style="width: 110px; text-align: right">
                                        <h:outputText value="#{itemDaNota.totalDoItem}">
                                            <f:convertNumber locale="pt_BR" minFractionDigits="2" />
                                        </h:outputText>
                                    </p:column>
                                </p:dataTable>
                            </p:rowExpansion> -->

                            <p:column headerText="Tipo" width="30"
                                style="text-align: center">
                                <h:outputText value="#{nota.tipoDeOperacao}" />
                            </p:column>

                            <p:column headerText="NF" width="110"
                                filterBy="#{nota.notaFiscal}" sortBy="#{nota.notaFiscal}">
                                <h:outputText value="#{nota.notaFiscal}" />
                            </p:column>

                            <p:column headerText="Emitente" width="400"
                                filterBy="#{nota.pessoa.nome}" filterMatchMode="contains"
                                sortBy="#{nota.pessoa.nome}">
                                <h:outputText value="#{fn:substring(nota.pessoa.nome,0,35)}" />
                            </p:column>

                            <p:column headerText="Data Emissão" width="110" filterBy="true" 
                                style="text-align: center">
                                <h:outputText value="#{nota.dataDeEmissao}">
                                    <f:convertDateTime pattern="dd/MM/yyyy" />
                                </h:outputText>
                            </p:column>

                            <p:column headerText="Valor" width="130"
                                style="text-align: right">
                                <h:outputText value="#{nota.valorTotal}">
                                    <f:convertNumber locale="pt_BR" minFractionDigits="2" />
                                </h:outputText>
                            </p:column>

                            <p:column headerText="Status" filterBy="#{nota.status}"
                                width="120" filterMatchMode="equals" style="text-align: center">
                                <f:facet name="filter">
                                    <p:selectOneButton onchange="PF('listNotaFiscal').filter()">
                                        <f:converter converterId="javax.faces.Character" />
                                        <f:selectItem itemValue="" itemLabel="T." />
                                        <f:selectItem itemValue="A" itemLabel="A." />
                                        <f:selectItem itemValue="C" itemLabel="C." />
                                    </p:selectOneButton>
                                </f:facet>
                                <h:outputText value="#{nota.status}" />
                            </p:column>
                        </p:dataTable>

                        <p:confirmDialog global="true" showEffect="fade"
                            hideEffect="fade" width="300">
                            <p:commandButton value="Sim" type="button"
                                styleClass="ui-confirmdialog-yes GreenButton"
                                icon="ui-icon-check" />
                            <p:commandButton value="Não" type="button"
                                styleClass="ui-confirmdialog-no RedButton" icon="ui-icon-close" />
                        </p:confirmDialog>
                    </p:panel>

Below the variable note, which loads the DataTable.

    public NotaFiscalBean() {
    notas = new LazyDataModel<NotaFiscal>() {

        private static final long serialVersionUID = 1L;

        @Override
        public NotaFiscal getRowData() {
            return super.getRowData();
        }

        @Override
        public List<NotaFiscal> load(int first, int pageSize, String sortField, SortOrder sortOrder,
                Map<String, Object> filters) {

            filtros.setPrimeiroRegistro(first);
            filtros.setQuantidadeRegistros(pageSize);
            filtros.setAscendente(SortOrder.ASCENDING.equals(sortOrder));
            filtros.setOrdenacao(sortField);

            if (filters.containsKey("pessoa.nome"))
                filtros.setFornecedor((String) filters.get("pessoa.nome"));
            else
                filtros.setFornecedor(null);

            if (filters.containsKey("notaFiscal")) {
                String temp = (String) filters.get("notaFiscal");
                filtros.setNotaFiscal(Integer.parseInt(temp));
            } else {
                filtros.setNotaFiscal(null);
            }

            setRowCount(notaFiscalDAO.quantidadeFiltrada(filtros));

            return notaFiscalDAO.listar(filtros);
        }
    };
}
    
asked by anonymous 12.10.2018 / 17:51

0 answers