Error in dataTable PrimeFaces

2

I'm doing a form in PrimeFaces , and when doing a CRUD operation, it works me without problems, but when listing the information from dataTable , it does not show me any information, in console tells me that the information was consulted successfully.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui">

<ui:composition template="/paginas/plantilla/plantilla.xhtml">

<ui:define name="tituloPagina"> 
    <h:outputText value="Gestion de Tipo de Identificacion" />
</ui:define>

    <ui:define name="cuerpo">

        <h:form>
            <p:messages id="capaMensajes" showDetail="true" autoUpdate="true" closable="true"></p:messages>
            <p:fieldset legend="formulario datos tipo de identificacion" toggleable="true" toggleSpeed="500">

            <p:toolbar>
                <f:facet name="right">
                    <p:commandButton value="Limpiar" id="cbLimpiar" action="#{TipoIdentificacionBean}" ></p:commandButton>
                    <p:commandButton value="Crear" id="cbCrear" action="#{TipoIdentificacionBean.crear()}" ></p:commandButton>
                    <p:commandButton value="Actualizar" id="cbActualizar" action="#{TipoIdentificacionBean.actualizar()}" ></p:commandButton>
                    <p:commandButton value="Eliminar" id="cbEliminar" action="#{TipoIdentificacionBean.eliminar()}" ></p:commandButton>
                    <p:commandButton value="Consultar" id="cbConsultar" action="#{TipoIdentificacionBean.consultar()}" ></p:commandButton>
                </f:facet>
            </p:toolbar>
                <br/>
            <p:panelGrid columns="2">

                <h:outputLabel for="itNombre" value="Nombre Tipo Identificacion" />
                <p:inputText  id="itNombre"  value="#{TipoIdentificacionBean.tipoIdentificacion.nvNombre}">
                <p:tooltip for="itNombre" value="Campo para Ingresar el Nombre del tipo de Identificacion"
                 showEffect ="explode" hideEffect="explode"></p:tooltip></p:inputText>  
            </p:panelGrid>
            </p:fieldset>

            <p:fieldset legend="Lista de Resultados" toggleable="true" toggleSpeed="500">
                <p:dataTable value="#{TipoIdentificacionBean.consultarTodos()}" var="tipoIdentificacion" id="idTablaTiposIdentificacion" 
                 emptyMessage="No existen Tipos de Identificacion para mostrar">

                <p:column headerText="Codigo"></p:column>
                <h:outputText value="#{tipoIdentificacion.inCodigo}" />
                <p:column headerText="Nombre"></p:column>
                <h:outputText value="#{tipoIdentificacion.nvNombre}" />
                <p:column headerText="Fecha Creacion"></p:column>
                <h:outputText value="#{tipoIdentificacion.dtFechaCreacion}" />
                <p:column headerText="Fecha Modificacion"></p:column>
                <h:outputText value="#{tipoIdentificacion.dtFechaModificacion}" />
                <p:column headerText="Fecha Eliminacion"></p:column>
                <h:outputText value="#{tipoIdentificacion.dtFechaEliminacion}" />
                <p:column headerText="Usuario Eliminacion"></p:column>
                <h:outputText value="#{tipoIdentificacion.segUsuarioByInCodigoUsuarioEliminacion}"/>
                <p:column headerText="Usuario Creacion"></p:column>
                <h:outputText value="#{tipoIdentificacion.segUsuarioByInCodigoUsuarioCreacion}"/>
                <p:column headerText="Usuario Modificacion"></p:column>
                <h:outputText value="#{tipoIdentificacion.segUsuarioByInCodigoUsuarioModificacion}"/>               

                </p:dataTable>
            </p:fieldset>       
        </h:form>   
    </ui:define>
</ui:composition>
<body>
</body>
</html>
    
asked by Diego Castaño 02.01.2017 в 03:29
source

2 answers

0

Refer to a property of the bean, for example listIdentifications, which is loaded in an initialization method marked with @PostConstruct, and create get / set. Something like this:

... private List<SegTipoIdentificacion> listaIdentificadores; ... @PostConstruct public void init (){ listaIdentificadores = consultarTodos(); } public List<SegTipoIdentificacion> getListaIdentificadores(){ return listaIdentificadores; }

and in the xhtml:

<p:dataTable value="#{TipoIdentificacionBean.listaIdentificadores}" 
    
answered by 03.01.2017 / 14:37
source
0

So that you can show your data in the view, you need to initialize your constructor, this is done with the annotation @PostConstruct , besides this method must contain a list or be a Map , so that it can show the desired values. This is already to the pleasure of the developer.

@PostConstruct
public void init(){
    nombre = "Hola primefaces";
}
    
answered by 16.05.2018 в 22:30