Autocomplete of Primefaces does not pass value to the bean

1

I have a problem with the autoComplete component of PrimeFaces. The value parameter is not being passed to my bean.

private String filtroClientes;

public List<String> listarFiltroDeClientes()
{
    List<String> lista = new ArrayList<String>();
    List<Cliente> clientesFiltrados = Clientes.buscarPorPartesDoNome(filtroClientes);


    for(int  i = 0; i < clientesFiltrados.size(); i++)
    {
        lista.add(clientesFiltrados.get(i).getNomeCliente());
    }

    return lista;

}

public String getFiltroClientes() {
    return filtroClientes;
}

public void setFiltroClientes(String filtroClientes) {
    this.filtroClientes = filtroClientes;
}

<p:autoComplete id="acCliente" value="#{projetosBean.filtroClientes}" 
							completeMethod="#{projetosBean.listarFiltroDeClientes()}"/>

When giving a print in the "Customers filter" it shows the null value, ie what was typed in the autocomplete input is not passing to the bean. Otherwise the component is working normally, I already tried to pass any string to filter the clients and the component worked.

Anyone who can help from now on thanks. Thanks!

    
asked by anonymous 26.08.2016 / 02:53

1 answer

1

The error is in the completeMethod:

<p:autoComplete id="acCliente" value="#{projetosBean.filtroClientes}" 
                        completeMethod="#{projetosBean.listarFiltroDeClientes()}"/>

Do not use "()" by calling mbean methods. Change to:

<p:autoComplete id="acCliente" value="#{projetosBean.filtroClientes}" 
                        completeMethod="#{projetosBean.listarFiltroDeClientes}"/>

As your autocompletion method was not even called, so the value was not set to value. With that change it should work.

    
01.09.2016 / 18:48