I have an autoComplete on the sale screen, when the user types the customer name I want it if it does not have any records it displays something like ADD NEW CUSTOMER, could anyone help me? I'm using 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();
}