I have a datatable which has filters on all columns. It also has pagination. Outside datatable I have a command button which saves the selected row (from the datatable) to the db. Problems are
1. Command button functionality does not work if filters are present.
It throws a NPE (as seen below) everything works fine if I remove filters.
java.lang.NullPointerException
at org.primefaces.component.datatable.DataHelper.decodeFilters(DataHelper.java:182)
at org.primefaces.component.datatable.DataTableRenderer.decode(DataTableRenderer.java:47)
at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:787)
at javax.faces.component.UIData.processDecodes(UIData.java:1162)
at org.primefaces.component.datatable.DataTable.processDecodes(DataTable.java:595)
2. SortBy does not work.
Here is the code of the xhtml file
Code: Select all
<p:dataTable value="#{myController.allUnRegisteredStudent}"
selection="#{registeredStudentController.selectedStudent}"
rowSelectListener="#{registeredStudentController.studentSelectListener}"
rowUnselectListener="#{registeredStudentController.studentUnSelectListener}"
selectionMode="multiple"
dblClickSelect="false"
var="item1"
id="tbl1"
paginator="true"
rows="5"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15"
>
<f:facet name="header">
<font color="white">Students </font>
</f:facet>
<p:column headerText="Last Name"
sortBy="#{item1.lastName}"
filterBy="#{item1.lastName}"
filterMatchMode="exact"
filterStyle="float:left"
style="width:10%">
<h:outputText value="#{item1.lastName}"/>
</p:column>
<p:column headerText="First Name"
sortBy="#{item1.firstName}"
filterBy="#{item1.firstName}"
filterStyle="float:left">
<h:outputText value="#{item1.firstName}"/>
</p:column>
<p:column headerText="course"
sortBy="#{item1.course.name}"
filterBy="#{item1.course.name}"
filterOptions="#{registeredStudentController.courseFilterOptions}"
filterStyle="float:left">
<h:outputText value="#{item1.department.name}"/>
</p:column>
</p:dataTable>
<p:commandButton value="Save"
action="#{myController.saveStudent}"
image="icon icon-edit"
immediate="true"
ajax="false"
styleClass="icon-button"/>