Datatable with jsf

Asked

Viewed 219 times

0

I’m having some difficulty using the datatable of the primefaces together with jsf, I tried to implement it in a certain way:

<p:tabView>
    <p:tab title="Alterar Usuarios">
        <h:form prependId="false">
            <h:panelGrid columns="2" cellpadding="2" cellspacing="2">
                <p:dataTable var="p" value="#{usuarioController.findAll()}"

                    border="1" cellpadding="2" cellspacing="2"

                    paginator="true" rows="2" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} 
                    {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="5,10,15"

                    >

                    <h:column>
                        <f:facet name="header">Id</f:facet>
                        <h:outputText value="${p.id}"></h:outputText>
                    </h:column>

                    <h:column>
                        <f:facet name="header">Nome</f:facet>
                        <h:outputText value="${p.nome}"></h:outputText>
                    </h:column>

                    <h:column>
                        <f:facet name="header">Sobrenome</f:facet>
                        <h:outputText value="${p.sobrenome}"></h:outputText>
                    </h:column>

                    <h:column>
                        <f:facet name="header">Email</f:facet>
                        <h:outputText value="${p.email}"></h:outputText>
                    </h:column>

                    <h:column>
                        <f:facet name="header">Data de Nascimento</f:facet>
                        <h:outputText value="${p.datanascimento}"></h:outputText>
                    </h:column>

                    <h:column>
                        <f:facet name="header">CPF</f:facet>
                        <h:outputText value="${p.cpf}"></h:outputText>
                    </h:column>

                    <h:column>
                        <f:facet name="header">Senha</f:facet>
                        <h:outputText value="${p.senha}"></h:outputText>
                    </h:column>

                    <h:column>
                        <f:facet name="header">Usuario</f:facet>
                        <h:outputText value="${p.usuario}"></h:outputText>
                    </h:column>

                    <h:column>
                        <f:facet name="header">Opçoes</f:facet>
                        <h:commandLink value="Alterar"
                            action="#{usuarioController.edit(pr)}"></h:commandLink>
                    </h:column>

                    <h:column>
                    <h:commandButton value="Voltar" action="welcome"></h:commandButton>
                    </h:column>
                </p:dataTable>
            </h:panelGrid>
        </h:form>
    </p:tab>
</p:tabView>

but I only get this look back:

inserir a descrição da imagem aqui

Someone could help me, I’m new with first faces, since grateful!

  • His method findAll() is working properly, meaning he is making the query?

  • Yes Techies, if I don’t use the <p:dataTable></p:dataTable> my fields are all exebidos.

2 answers

1


I managed to get the following code by changing the <h:column> </h:column> for <p:column> </p:column>. In case someone else has the same doubts that I, and this the solution.

0

Try this. At the beginning of your xhtml file put:

<f:metadata>
    <f:viewParam name="dummy" />
    <f:event listener="#{usuarioController.findAll()}"
        type="preRenderView"></f:event>
</f:metadata>

Then in the value of your dataTable you spend your array

value="#{usuarioController.lista}"
  • techies did not give Right, but thank you very much For the attention.

  • Some mistake is coming up?

Browser other questions tagged

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