I am using PF 5.1. I want to filter Primefaces datatable (date column) by calendar set primefaces calendar here .
I have the requirement too on my site. However I have a different implementation from @stg. By the time of this writing, I'm using Primefaces 5.0. Here is the piece of work that does the job:
XHTML site
...
Java site
@ManagedBean
@SessionScoped
public class Controller {
public boolean filterByDate(Object value, Object filter, Locale locale) {
if( filter == null ) {
return true;
}
if( value == null ) {
return false;
}
return DateUtils.truncatedEquals((Date) filter, (Date) value, Calendar.DATE);
}
}
Site note
DateUtils.truncateEquals()
because my date column contains timestamp. This is to ensure that I'm filtering on the particular date regardless of timestamp. If my input is date only then table view would be empty.
is needed to reset table view when the filter input is remove. I wasn't sure whether this is the correct way to handle this, I'm currently using it until I find a better one.