I have a dataTable with dynamic Columns.
So I use primefaces 5.3 and jsf 2.2
Here is code :
<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() load all students.
Exception :
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)[...]
something is wrong here??