0
當我嘗試加載頁面時數據表爲空。使用<h:dataTable ... />
數據顯示在行中。然而在進一步檢查之後,列表實際上是寫成的......但它好像直接在數據表的value屬性中使用列表的toString()。哪裏不對?沒有數據顯示在數據表中
支持bean
@Named
@RequestScoped
public class QuestionTableBacking {
@Inject
private QuestionServiceLocal questionService;
public List<Question> getAllQuestions() {
return questionService.getAllQuestions();
}
}
的facelet文件
<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>
這是我的螢火看到
<p:datatable value="[[email protected], [email protected], [email protected],..... var="question">
<p:column>
</p:column>
<p:column><a href="/myapp/report.faces">Report</a>
</p:column>
</p:datatable>
POM文件(它們包含在正確的父元素)
<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>
警告:此頁面調用XML名稱空間http://primefaces.org/ui 用前綴p聲明,但該名稱空間不存在taglibrary。
完整的文件:
<?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>
你有沒有在你的項目類路徑中包含primefaces jar?你知道你正在使用CDI?因爲你還沒有標記你的作爲cdi之一的問題,「@Named」和「@Inject」不是JSG anotations ... – Daniel 2012-04-22 11:37:57
如果你想使用素數面臨庫你必須將它添加到你的項目,同樣的方式你添加jsf罐子 – Daniel 2012-04-22 11:44:02
嘗試刪除/重新添加primefaces jar文件,也許刷新你的項目,也許重新打開日食... – Daniel 2012-04-22 11:53:23