0
I have a autoComplete
on the sales screen, when the user enters the customer’s name I want that if it has no record it displays something like "ADD NEW CUSTOMER",
I’m wearing primefaces:
<p:autoComplete id="cliente" required="true"
styleClass="Container100 Fnone MarAuto Fs15" placeholder="Cliente"
rendered="#{loginControler.vendaFutura eq true}"
completeMethod="#{pessoaControle.autoComplete}"
var="cli" onclick="this.select();"
itemLabel="#{cli.nome}"
itemValue="#{cli.id.toString()}"
converter="#{pessoaControle.converter()}"
value="#{vendaControle.venda.pessoa}"
queryDelay="500"
dropdown="true" scrollHeight="550"
style="margin-right: 30px;">
<p:ajax event="itemSelect" update="painelCpf totalReceber console totalReceberVencido painelpto" listener="#{vendaControle.enviaCpfCnpj()}"/>
<f:facet name="itemtip">
<h:panelGrid columns="2" cellpadding="5">
<h:outputText value="CPF/CNPJ" />
<h:outputText style="color: blue" value="#{cli.documentoFederal}" />
<h:outputText value="RG/IE" />
<h:outputText style="color: blue" value="#{cli.documentoEstadual}" />
<h:outputText value="Tel" />
<h:outputText style="color: blue" value="#{cli.fone}" />
</h:panelGrid>
</f:facet>
</p:autoComplete>
My List
public List<Pessoa> autoCompletePessoa(String campo, String cons) {
cons = cons.toUpperCase();
String consulta = "FROM Pessoa AS i"
+ " WHERE i.validaFuncionario is false AND i.ativo is true AND (i." + campo + ") LIKE ('" + cons + "%')"
+ " ORDER BY i." + campo;
Query query = getEntityManager().createQuery(consulta);
return query.setMaxResults(20).getResultList();
}
Thanks for the answer, already solved my problem
– Leandro Santos