Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NullPointerException at org.primefaces.model.BeanPropertyComparator.compare

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)
like image 268
user3586195 Avatar asked Mar 09 '15 18:03

user3586195


1 Answers

Simply put "h:form" element was missing. That's all.

like image 55
user3586195 Avatar answered Oct 19 '22 13:10

user3586195