DataTable with jsf

0

I'm having a hard time using the primefaces datatable along with jsf, I've tried to implement it in a 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 only this visual returns me:

Someone could help me, I'm new with primefaces, since I'm grateful!

    
asked by anonymous 18.02.2016 / 16:38

2 answers

1

I was able to sort the following code by changing the <h:column> </h:column> by <p:column> </p:column> . If someone else has the same doubts as me, this is the solution.

    
19.02.2016 / 10:12
0

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

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

Then in% with% of your value you pass dataTable

value="#{usuarioController.lista}"
    
18.02.2016 / 18:13