Search
Calendar
October 2016
S M T W T F S
« Sep    
 1
2345678
9101112131415
16171819202122
23242526272829
3031  
Your widget title
Archives

PostHeaderIcon (long tweet) When ‘filter’ does not work with Primefaces’ datatable

Abstract

Sometimes, the filter function in Primefaces <p:datatable/> does not work when the field on which filtering is operated typed as an enum.

Explanation

Actually, in order to filter, Primefaces relies on a direct '=' comparison. The hack to fix this issue is to force Primefaces to compare on the enum name, and not by a reference check.

Quick fix

In the enum class, add the following block:

public String getName(){ return name(); }

Have the datatable declaration to look like:

<p:dataTable id="castorsDT" var="castor" value="#{managedCastorListManagedBean.initiatedCastors}" widgetVar="castorsTable" filteredValue="#{managedCastorListManagedBean.filteredCastors}">

Declare the enum-filtered column lke this:

<p:column sortBy="#{castor.castorWorkflowStatus}" filterable="true" filterBy="#{castor.castorWorkflowStatus.name}" filterMatchMode="in">
  <f:facet name="filter">
    <p:selectCheckboxMenu label="#{messages['status']}" onchange="PF('castorsTable').filter()">

      <f:selectItems value="#{transverseManagedBean.allCastorWorkflowStatuses}" var="cws" itemLabel="#{cws.name}" itemValue="#{cws.name}"/>
    </p:selectCheckboxMenu>
  </f:facet>
</p:column>

Notice how the filtering attribute is declared:

filterable="true" filterBy="#{castor.castorWorkflowStatus.name}" filterMatchMode="in"

In other terms, the comparison is forced the rely on equals() of class String, through the calls to getName() and name().

PostHeaderIcon Retours du Devoxx France 2016 (4): Gradle: Harder, Better, Stronger, Faster

La conference est animee par Andres Almiray de Canoo Fellow, un Java Champion qui nous vient du Mexique. Officiellement, il s’agit de presenter Gradle pour un usage avance ; neanmoins, Andres dissimule a peine son intention de nous faire quitter Maven pour Gradle.

Read the rest of this entry »

PostHeaderIcon Jonathan LALOU recommends… Stephane TORTAJADA

I wrote the following notice on Stephane TORTAJADA‘s profile on LinkedIn:

I had reported to Stephane for one year. I recommend Stephane for his management, that is based on a few principles:
* understand personally technical and functional problems
* allow team mates to make errors, in order to learn from them
* protect team mates from external aggressions and impediments
* escalating up and down the relevant information

PostHeaderIcon Jonathan LALOU recommends… Ahmed CHAARI

I wrote the following notice on Ahmed CHAARI‘s profile on LinkedIn:

Ahmed has shown his ability to absorb and learn complex technologies, as well as improve his skills in a short time and a not-so-easy environment. This is why I consider Ahmed as a software engineer to recommend for any Java-focused team.

PostHeaderIcon Jonathan LALOU recommands… Sidney COHEN

I wrote the following notice on Sidney COHEN‘s profile on LinkedIn:

Sidney has a deep knowledge of the technologies he uses, such as Tibco systems. In several occasions, he was able to liaise with the key people of the right teams, perform the good actions and deliver the best solutions to various issues. Moreover, he has learnt complex Java technologies in a short time.
I recommend Sidney as a good worker and a friendly team mate