I am creating a mock-up using PrimeFaces 5.1. The sortBy feature is throwing up a NPE. Tracing the stack lets me believe that initially it needs a default sortBy attribute at the datatable level. Here's the XHTML. Did anyone manage to use the sortyBy feature of PrimeFaces 5.1 datatable?
<?xml version='1.0' encoding='UTF-8' ?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head>
<h:outputStylesheet library="default" name="css/newcss.css"/>
</h:head>
<h:body>
<p:panel header="Application List" toggleable="true" toggleTitle="Toggler">
<p:dataTable var="worker" value="#{workerPanel.workerList}"
>
<p:column sortBy="#{worker.lastName}"
headerText="Last Name"
styleClass="font12px"
>
<h:outputText value="#{worker.lastName}"/>
</p:column>
Stack trace:
Throwable javax.faces.FacesException: java.lang.NullPointerException
at org.primefaces.model.BeanPropertyComparator.compare(BeanPropertyComparator.java:90)
at java.util.TimSort.countRunAndMakeAscending(TimSort.java:324)
at java.util.TimSort.sort(TimSort.java:189)
at java.util.TimSort.sort(TimSort.java:173)
at java.util.Arrays.sort(Arrays.java:659)
at java.util.Collections.sort(Collections.java:217)
at org.primefaces.component.datatable.feature.SortFeature.singleSort(SortFeature.java:147)
at org.primefaces.component.datatable.feature.SortFeature.encode(SortFeature.java:105)
at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:78)
Simply put "h:form" element was missing. That's all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With