updating filling information after using autoComplete

0

I'm creating a form in JSF and primeface, and I have an autoComplete here. Only when I finish filling up my autoComplete, I want to render a part of my form.

So far I have been able to hide the fields, which in the case would be the panelGrid with id="InformationService"

In my CPF it looks like this: Logic that did not render because it is still null, I want it to come out of the filled autoComplete it render my panelGrid.

@Transient
public boolean isClienteNovo() {
    return this.getCpf() == null;
}

@Transient
public boolean isClienteExistente() {
    return !isClienteNovo();
}

<ui:composition 
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui" 
xmlns:o="http://omnifaces.org/ui">

    <p:panelGrid columns="4" id="painel" style="width: 100%; margin-top: 20px" columnClasses="rotulo, campo, rotulo, campo">

        <p:outputLabel value="Cpf" for="cpf" />
        <p:autoComplete id="cpf"  value="#{cadastroServicoBean.servico.cliente}" size="13" required="true" dropdown="true"
                        completeMethod="#{cadastroServicoBean.completaCliente}" var="client" itemLabel="#{client.cpf}" 
                        forceSelection="true" minQueryLength="2" />

        <p:outputLabel value="Carro" for="carro" />
        <p:selectOneMenu id="carro" value="#{cadastroServicoBean.servico.carro}" required="true">
            <f:selectItem  itemLabel="--Selecione--" noSelectionValue="true"/>
            <f:selectItems value="#{cadastroServicoBean.carros}" var="carro" itemLabel="#{carro.modeloCarro.nome} : #{carro.placa}"  />
        </p:selectOneMenu>

        <p:outputLabel value="Data do Serviço" for="dataServico" />
        <p:calendar id="dataServico" value="#{cadastroServicoBean.servico.diaServico}"  size="13" pattern="dd/MM/yyyy" required="true" />

        <p:outputLabel value="Data da Garantia" for="dataGarantia" />
        <p:calendar id="dataGarantia" value="#{cadastroServicoBean.servico.diaGarantia}"  size="13" pattern="dd/MM/yyyy"  required="true"/>

        <p:outputLabel value="valor" for="valor" />
        <p:inputText  styleClass="moeda" value="#{cadastroServicoBean.servico.valor}"  size="5" id="valor"  required="true">
            <f:convertNumber pattern="#,##0.00" />
        </p:inputText>

        <p:outputLabel value="Pagamento" for="pagamento" />
        <p:selectOneMenu id="pagamento" value="#{cadastroServicoBean.servico.pagamento}" style="width: 138px" required="true">
            <f:selectItem itemLabel="--Selecione--" noSelectionOption="true"  />
            <f:selectItems value="#{cadastroServicoBean.pagamentos}" var="pgto" itemLabel="#{pgto.descricao}" itemValue="#{pgto}" />
        </p:selectOneMenu>

        <p:outputLabel for="statusServ"  value="Status Serviço"/>
        <p:selectOneMenu id="statusServ"  value="#{cadastroServicoBean.servico.statusServico}" style="width: 138px" required="true">
            <f:selectItem itemLabel="--Selecione--" noSelectionOption="true"/>
            <f:selectItems value="#{cadastroServicoBean.statusServicos}" var="stsServ" itemLabel="#{stsServ.descricao}" itemValue="#{stsServ}" />
        </p:selectOneMenu>

        <p:outputLabel value="Subtotal" style="font-weight:bold;" />
        <p:outputLabel style="font-weight:bold;" />

        <p:outputLabel value="desconto"  for="desc" />
        <p:inputText id="desc" value="#{cadastroServicoBean.servico.desconto}"  styleClass="moeda">
            <f:convertNumber  pattern="#,##0.00" />
        </p:inputText>

        <p:outputLabel value="Total Serviço" style="font-weight:bold;" />
        <p:outputLabel style="font-weight:bold;"  />
    </p:panelGrid>


    <p:panelGrid columns="2" id="informacaoClienteServico" rendered="#{cadastroServicoBean.cliente.clienteExistente}">
        <f:facet name="header">Informações do Cliente</f:facet>

        <p:outputLabel value="Cliente:" rendered="#{cadastroServicoBean.cliente.clienteExistente}" />
        <p:outputLabel value="#{cadastroServicoBean.servico.cliente.nome}"  rendered="#{cadastroServicoBean.cliente.clienteExistente}"/>

        <p:outputLabel value="Cliente:" rendered="#{cadastroServicoBean.cliente.clienteExistente}" />
        <p:outputLabel value="#{cadastroServicoBean.servico.cliente.nome}" rendered="#{cadastroServicoBean.cliente.clienteExistente}" />

        <p:outputLabel value="Telefone Fixo" rendered="#{cadastroServicoBean.cliente.clienteExistente}" />
        <p:outputLabel value="#{cadastroServicoBean.servico.cliente.telefoneFixo}" rendered="#{cadastroServicoBean.cliente.clienteExistente}" />

        <p:outputLabel value="Telefone Fixo" rendered="#{cadastroServicoBean.cliente.clienteExistente}" />
        <p:outputLabel value="#{cadastroServicoBean.servico.cliente.telefoneCelular}" rendered="#{cadastroServicoBean.cliente.clienteExistente}" />         
    </p:panelGrid>
<br />
<br />

    
asked by anonymous 22.03.2017 / 21:10

1 answer

0

You can use ajax :

<p:autoComplete id="cpf"  value="#{cadastroServicoBean.servico.cliente}" size="13" required="true" dropdown="true"
                        completeMethod="#{cadastroServicoBean.completaCliente}" var="client" itemLabel="#{client.cpf}" 
                        forceSelection="true" minQueryLength="2" >
<p:ajax event="itemSelect" update="informacaoClienteServico" listener=""/>
</p:autoComplete> 

Where is listener you create a method that will change the value of clientExist to true .

    
22.03.2017 / 22:59