我有一个带有动态列的dataTable。
所以我使用primefaces 5.3和jsf 2.2
这是代码:
<h:form id="form1">
<p:dataTable var="etudiant" widgetVar="etdTable" paginator="true" rows="10"
rowsPerPageTemplate="5,10,15" value="#{etudiantController.etudiants}"
lazy="false" emptyMessage="Aucune etudiant trouvé"
filteredValue="#{etudiantController.filteredEtudiants}">
<p:column filterBy="#{etudiant.nomEtudiant}" filterMatchMode="exact">
<f:facet name="header">
<h:outputText value="Nom" />
</f:facet>
<h:outputText value="#{etudiant.nomEtudiant}" />
</p:column>
[...]
Bean:
private List<Etudiant> etudiants;
private List<Etudiant> filteredEtudiants;
public List<Etudiant> getEtudiants() {
return etudiantService.getAllEtudiants();
}
public List<Etudiant> getFilteredEtudiants() {
return this.filteredEtudiants;
}
public void setFilteredEtudiants(List<Etudiant> filteredEtudiants) {
this.filteredEtudiants = filteredEtudiants;
}
getAllEtudiants()加载所有学生。
例外:
java.lang.NullPointerException
at org.primefaces.component.datatable.feature.FilterFeature.filter(FilterFeature.java:150)
at org.primefaces.component.datatable.feature.FilterFeature.encode(FilterFeature.java:117)
at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:78)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:924)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863) [...]
java.lang.IllegalStateException: CDATA tags may not nest
at com.sun.faces.renderkit.html_basic.HtmlResponseWriter.startCDATA(HtmlResponseWriter.java:681) at javax.faces.context.ResponseWriterWrapper.startCDATA(ResponseWriterWrapper.java:179)[...]
这里出了什么问题?
答案 0 :(得分:0)
我不确定,但你是否尝试将列表推理出来?
试试这个:
private List<Etudiant> filteredEtudiants = new ArrayList<>();