When I try to load the page the datatable is empty. Using the <h:dataTable ... /> the data shows up in the rows. However after further inspection the list is actually written….but it seems like it uses the toString() of the list directly in the value attribute of the datatable. What is wrong?
Backing bean
@Named
@RequestScoped
public class QuestionTableBacking {
@Inject
private QuestionServiceLocal questionService;
public List<Question> getAllQuestions() {
return questionService.getAllQuestions();
}
}
Facelet file
<h:form>
<p:dataTable value="#{questionTableBacking.allQuestions}" var="question" >
<p:column>
<h:outputText value="#{question.description}" />
</p:column>
<p:column>
<h:link outcome="report" value="Rapporter" />
</p:column>
</p:dataTable>
</h:form>
This is what I see in firebug
<p:datatable value="[com.mycompany.myapp.domain.Question@7cf9175c, com.mycompany.myapp.domain.Question@456cd91d, com.mycompany.myapp.domain.Question@6d222286,..... var="question">
<p:column>
</p:column>
<p:column><a href="/myapp/report.faces">Report</a>
</p:column>
</p:datatable>
POM file ( they are contained in correct parent elements )
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.2</version>
<scope>compile</scope>
</dependency>
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>
<layout>default</layout>
</repository>
Warning: This page calls for XML namespace http://primefaces.org/ui
declared with prefix p but no taglibrary exists for that namespace.
Complete file:
<?xml version="1.0" encoding="UTF-8"?>
<!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:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:o="http://openfaces.org/">
<h:head>
<title>Simple JSF Facelets page</title>
</h:head>
<h:body>
<ui:composition template="templates/masterLayout.xhtml">
<ui:define name="windowTitle">Question</ui:define>
<ui:define name="content">
<div id="page-intro">
<h2>Titile</h2>
<p>Blah blah</p>
</div>
<h:form>
<div class="question-filter-container">
<o:inputTextFilter id="quesiton-filter" styleClass="input-text question-filter" for="question-table"
expression="#{question.description}"
promptText="" />
</div>
<o:dataTable value="#{questionTableBacking.allQuestions}" var="question" rowKey="#{question.id}"
id="question-table" pageSize="25" applyDefaultStyle="false"
cellspacing="0">
<f:facet name="below">
<o:dataTablePaginator id="paginator" pageNumberPrefix="Side" pageCountPreposition="av"
styleClass="question-paginator" />
</f:facet>
<o:column>
<h:outputText value="#{question.description}" />
</o:column>
<o:column bodyClass="question-operations">
<h:link outcome="report" value="Report" />
</o:column>
</o:dataTable>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
#{question.description}should be turned intoStringvalue that is inside the currently iteratedquestionobjects.descriptionpropety , isn’t that what you see in the output? if that the case , then its all fine…EDIT
after looking at your question update it seems that you haven’t added primefaces jar to your project…
have you added xmlns:p=”http://primefaces.org/ui to your xhtml file?