Problem with p:datatable, ajax, ui:include

Asked

Viewed 149 times

1

I have a problem, I have a p:datatable that does not work the "sortBy", nor the pagination. When I test the code of this table on a simple page it works, but when I use it in my project it doesn’t work. In my project I call the page that has the table through a table search the bean data, but it does not work either ordering or pagination. I am using CDI with @Named, @Viewscope and @Inject, I have tested with other scopes and the result is the same :(

Table Code:

<h:form>    
<p:dataTable value="#{moduloController.modulos}" var="m" id="tabModulos"
                        emptyMessage="Nenhum módulo localizado." paginator="true" rows="10"
                        paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
                        rowsPerPageTemplate="5,10,15">

                        <p:column  headerText="Nome" width="40%" sortBy="#{m.nome}">
                            <h:outputText value="#{m.nome}" />
                        </p:column>

                        <p:column  headerText="Descrição" width="40%" sortBy="#{m.descricao}">
                            <h:outputText value="#{m.descricao}" />
                        </p:column>


                        <p:column headerText="Módulo Principal" width="20%" 
                            styleClass="align-center" sortBy="#{m.topModulo.nome}">
                            <h:outputText value="#{m.topModulo.nome}" />
                        </p:column>                 

                    </p:dataTable>
</h:form>

Insertion of the page containing the table is done through the following code:

            <h:panelGroup id="painelConteudo" layout="block">
                <ui:include src="#{menuController.pageLink}.xhtml"/>
            </h:panelGroup>

Testing this table code on a common page it works perfectly.

Comparing the debug, via the Chrome Veloper tools I realized that on the page that is made the inclusion, ajax does not call the element for update;

Follow the debug by the page that does not work:

<partial-response id="j_id1">
<changes>
<update id="j_id1:javax.faces.ViewState:0">-8477971442835400176:4133945171221710420</update>
</changes>
</partial-response>

and now debug by simple page... where it is possible to view the table to be ordered.

<partial-response id="j_id1">
<changes>
<update id="form:j_idt14"><tr data-ri="0" class="ui-widget-content ui-datatable-even" role="row"><td role="gridcell">Administrativo</td><td role="gridcell">Módulo de Administração do Sistema</td><td role="gridcell" class="align-center"></td></tr><tr data-ri="1" class="ui-widget-content ui-datatable-odd" role="row"><td role="gridcell">Caixa</td><td role="gridcell">Gerencie o caixa</td><td role="gridcell" class="align-center"></td></tr><tr data-ri="2" class="ui-widget-content ui-datatable-even" role="row"><td role="gridcell">Calendário</td><td role="gridcell">Agende seus compromissos</td><td role="gridcell" class="align-center"></td></tr><tr data-ri="3" class="ui-widget-content ui-datatable-odd" role="row"><td role="gridcell">Cargos</td><td role="gridcell">Cadastro de Cargos</td><td role="gridcell" class="align-center">Administrativo</td></tr><tr data-ri="4" class="ui-widget-content ui-datatable-even" role="row"><td role="gridcell">CFOP</td><td role="gridcell">Cadastro de CFOP</td><td role="gridcell" class="align-center">Administrativo</td></tr><tr data-ri="5" class="ui-widget-content ui-datatable-odd" role="row"><td role="gridcell">Clientes</td><td role="gridcell">Cadastro de Clientes</td><td role="gridcell" class="align-center">Administrativo</td></tr><tr data-ri="6" class="ui-widget-content ui-datatable-even" role="row"><td role="gridcell">Colaboradores</td><td role="gridcell">Cadastro de Colaboradores</td><td role="gridcell" class="align-center">Administrativo</td></tr><tr data-ri="7" class="ui-widget-content ui-datatable-odd" role="row"><td role="gridcell">Compras</td><td role="gridcell">Gerencie de compra de insumos e produtos</td><td role="gridcell" class="align-center"></td></tr><tr data-ri="8" class="ui-widget-content ui-datatable-even" role="row"><td role="gridcell">Contas a Pagar</td><td role="gridcell">Gerencie as contas a pagar</td><td role="gridcell" class="align-center"></td></tr><tr data-ri="9" class="ui-widget-content ui-datatable-odd" role="row"><td role="gridcell">Contas a Receber</td><td role="gridcell">Gerencie as contas a receber</td><td role="gridcell" class="align-center"></td></tr></update>
<update id="j_id1:javax.faces.ViewState:0">4054556111108695514:3140532311518801280</update>
<extension ln="primefaces" type="args">{"totalRecords":27}</extension>
</changes>
</partial-response>

It’s like the first faces aren’t locating the form. I have already put the form inside the page to be included and also on the page that makes the insertion, the result is the same... ie does not work ordering, nor pagination in this case. Does anyone have any suggestions on how to resolve?

  • Include table code only has that you posted or has something else?

No answers

Browser other questions tagged

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