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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s