Primefaces : How to change to the autocomplete component isn’t case sensitive?

Check your implementation driven by “completeMethod”. In this implementation you should perform the dealings só that this query isn’t case sensitive.

First Example, change your matches:

file.xhtml

<p:autoComplete 
    {...} 
    completeMethod="#{myController.filterPlaces}" 
{...} />
</p:autoComplete>

controller.java

public List<Pessoa> filterPlaces(final String filtro) {
    return getPlace().stream()
            .filter(f -> StringUtils.containsIgnoreCase(f.getName(), filtro.trim()))
            .collect(Collectors.toList());
}

Second Example, change your query:

public List<Place> filterByName(String name) {
    Criteria criteria = getSession().createCriteria(Place.class);
    criteria.add(Restrictions.like("name", name).ignoreCase());
    return criteria.list();
}

Leave a comment