1

I have a <h:dataTable> that renders perfectly, but when I change it to p:dataTable it vanishes completely

Unfortunately I am not able to upload images yet, but other PrimeFaces components on the same page are rendering perfectly.

Here is the XHTML file:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>Admin</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    </h:head>
    <body>

    <ui:composition template="template.xhtml">

        <ui:define name="content">
            <div id="header">
                <div id="logo">
                    <h:form>
                        <h:link outcome="userHome">
                            <h:graphicImage value="resources/img/logo.png" alt="Monash South Africa - A campus of Monash Univeristy Australia"/>
                        </h:link>
                    </h:form>
                </div>

                <ul>
                    <h:form>
                        <li>Help</li>
                        <li><h:link value="Logout" outcome="login"></h:link></li>
                    </h:form>
                </ul>
            </div>

            <h:form id="adminHome">
                <p:menubar>
                    <p:menuitem value="Home" icon="ui-icon-home" url="faces/userHome.xhtml" style="margin-left: 0px !important; margin-right: 0px !important;"/>
                    <p:menuitem value="View Applications" icon="ui-icon-document" url="faces/userHome.xhtml" style="margin-left: 0px !important; margin-right: 0px !important;"/>
                    <p:submenu label="Manage" icon="ui-icon-document" style="margin-left: 0px !important; margin-right: 0px !important;">                        
                        <p:menuitem value="GPA Grants" url="#" style="padding-left: 0% !important; margin-left: 0% !important;"/>
                        <p:menuitem value="Achievement Levels" url="#" style="padding-left: 0% !important; margin-left: 0% !important;"/>
                        <p:menuitem value="Marks" url="#" style="padding-left: 0% !important; margin-left: 0% !important;"/>
                    </p:submenu>
                </p:menubar>

                        <h1><h:outputText value="List"/></h1>
                        <p:dataTable value="#{applicationFacade.applications}" var="item">
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Applicationid"/>
                                </f:facet>
                                <h:outputText value="#{item.applicationid}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Studentid"/>
                                </f:facet>
                                <h:outputText value="#{item.studentid}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Surname"/>
                                </f:facet>
                                <h:outputText value="#{item.surname}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Firstname"/>
                                </f:facet>
                                <h:outputText value="#{item.firstname}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Secondname"/>
                                </f:facet>
                                <h:outputText value="#{item.secondname}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Southafricanid"/>
                                </f:facet>
                                <h:outputText value="#{item.southafricanid}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Studyaddress"/>
                                </f:facet>
                                <h:outputText value="#{item.studyaddress}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Homeaddress"/>
                                </f:facet>
                                <h:outputText value="#{item.homeaddress}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Telnum"/>
                                </f:facet>
                                <h:outputText value="#{item.telnum}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Cellnum"/>
                                </f:facet>
                                <h:outputText value="#{item.cellnum}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Email"/>
                                </f:facet>
                                <h:outputText value="#{item.email}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Coursetitle"/>
                                </f:facet>
                                <h:outputText value="#{item.coursetitle}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Coursecode"/>
                                </f:facet>
                                <h:outputText value="#{item.coursecode}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Levelofstudy"/>
                                </f:facet>
                                <h:outputText value="#{item.levelofstudy}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Agree"/>
                                </f:facet>
                                <h:outputText value="#{item.agree}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Approvalcount"/>
                                </f:facet>
                                <h:outputText value="#{item.approvalcount}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Accountid"/>
                                </f:facet>
                                <h:outputText value="#{item.accountid}"/>
                            </h:column>
                        </p:dataTable>
            </h:form>

        </ui:define>

    </ui:composition>


</body>
</html>

and here is the bean:

package DataAccess;

import Entities.Application;
import java.util.List;
import javax.ejb.Stateless;
import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;


@Stateless
@Named
public class ApplicationFacade extends AbstractFacade<Application> {
    @PersistenceContext(unitName = "com.mycompany_WSAMS_war_1.0-SNAPSHOTPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public ApplicationFacade() {
        super(Application.class);
    }

    public List<Application> getApplications() {
        return em.createNamedQuery("Application.findAll").getResultList();
    }    
}

I am using primefaces lib 4.0, does anyone know how to fix this issue, if it helps the primefaces selectOneMenu and radio buttons do not allow me to interact with them.

Kukeltje
  • 12,223
  • 4
  • 24
  • 47

2 Answers2

0

Change the h:column tags to p:column (Primefaces columns). After changing that, the datatable rendered for me.

You can even shorten the column definitions to:

<p:column headerText="Applicationid">
   <h:outputText value="#{item.applicationid}"/>
 </p:column>
Tom11
  • 2,419
  • 8
  • 30
  • 56
Slettal
  • 1,007
  • 13
  • 19
0

You need to add the <h:panelGrid id="yourID"> around your dataTable. When </h:panelGrid> is closed then you can place your <p:commandButton update="yourID" action="yourAction"/>

Because, prime rendered only when you call to render. Else the content would rendered when you reload the page.

Hope this is helpfull

7upus
  • 1
  • This does not make sense to me. You most likely refer to https://stackoverflow.com/questions/9010734/why-do-i-need-to-nest-a-component-with-rendered-some-in-another-component-w but that does not play a role here. Not at all – Kukeltje Apr 29 '20 at 10:55