Form with null values

Asked

Viewed 152 times

0

My Vies is coming with only one null form, while the others are with the correct values here is my view:

<h:head>
    <title>Novo Cliente</title>
</h:head>
<h:body>
    <ui:composition template="templateAdmin.xhtml">
        <ui:define name="conteudoAdmin">
            <!-- inicio conteudo de novo cliente -->
            <div class="row mt">
                <div class="col-lg-12">
                    <div class="form-panel">
                        <h4 class="mb"><i class="fa fa-angle-right"></i> Novo Cliente</h4>

                        <h:form class="form-horizontal style-form" id="tipoCliente">
                            <th></th>
                            <h:commandButton  class="btn btn-primary" value="Pessoa Física" action="#{clienteController.pessoaFisica()}" />
                            <p:spacer width="75" height="10" />
                            <h:commandButton  class="btn btn-success" value="Pessoa Jurídica" action="#{clienteController.pessoaJuridica()}" /> 
                            <br></br>
                            <br></br>
                            <br></br>
                        </h:form>

                        <h:form class="form-horizontal style-form" id="buscaCliente" >
                            <!--inicio condicao CPF CNPJ-->
                            <div class="form-group">
                                <h:outputLabel class="col-sm-2 col-sm-2 control-label" value="CPF" for="cpf" rendered="#{clienteController.cliente.tipoPessoa == 0}" />  
                                <h:outputLabel class="col-sm-2 col-sm-2 control-label" value="CNPJ" for="cnpj" rendered="#{clienteController.cliente.tipoPessoa == 1}" />  
                                <div class="col-sm-10">
                                    <p:inputMask mask="999.999.999-99" id="cpf"  
                                                 value="#{clienteController.cliente.identificacao}"  
                                                 rendered="#{clienteController.cliente.tipoPessoa == 0}" 
                                                 /> 


                                    <p:inputMask mask=" 99.999.999/9999-99" id="cnpj"  
                                                 value="#{clienteController.cliente.identificacao}"  
                                                 rendered="#{clienteController.cliente.tipoPessoa == 1}" 
                                                 /> 
                                    <p:spacer width="55" height="10" />
                                    <h:commandButton  id="verifcarCliente" value="Verificar Cliente" 
                                                      actionListener="#{clienteController.buscaClienteCPFCNPJ()}" >

                                    </h:commandButton>
                                </div>
                            </div>
                        </h:form>

                        <h:form class="form-horizontal style-form" id="dadosCliente" rendered="#{clienteController.existeCliente == false}" >
                            <div class="form-group">
                                <h:outputLabel  value="Razão Social" class="col-sm-2 col-sm-2 control-label" />
                                <div class="col-sm-10">
                                    <h:inputText value="#{clienteController.cliente.nomeFantasia}" class="form-control" />
                                </div>
                            </div>

                            <div class="form-group">
                                <h:outputLabel value="Nome" class="col-sm-2 col-sm-2 control-label" />
                                <div class="col-sm-10">
                                    <h:inputText value="#{clienteController.cliente.nome}" class="form-control" />
                                </div>
                            </div>

                            <div class="form-group">
                                <h:outputLabel for="mask" value="Data de Nascimento" class="col-sm-2 col-sm-2 control-label" />
                                <div class="col-sm-10">
                                    <p:inputMask mask="99/99/9999" id="dataNasc"  
                                                 value="#{clienteController.dataNascimento}" /> 

                                </div>
                            </div>

                            <div class="form-group">
                                <h:outputLabel class="col-sm-2 col-sm-2 control-label" value="Telefone" for="tel" />  
                                <div class="col-sm-10">
                                    <p:inputMask mask="(99)9999-9999" id="tel"  
                                                 value="#{clienteController.cliente.telefone}"/> 
                                </div>
                            </div>

                            <div class="form-group">
                                <h:outputLabel  value="E-mail" class="col-sm-2 col-sm-2 control-label" />
                                <div class="col-sm-10">
                                    <h:inputText id="email" value="#{clienteController.cliente.email}" class="form-control" required="true"
                                                 pt:placeholder="ex: [email protected]"
                                                 validatorMessage="Endereço de email inválido.">
                                        <f:validateRegex pattern="[\w\.-]*[a-zA-Z0-9_]@[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]" />
                                    </h:inputText>
                                    <h:message for="email" />
                                </div>
                            </div>

                            <div class="form-group">
                                <h:outputLabel  value="Site" class="col-sm-2 col-sm-2 control-label" />
                                <div class="col-sm-10">
                                    <h:inputText id="site" value="#{clienteController.cliente.site}" class="form-control" 
                                                 validatorMessage="Endereço de site inválido.">
                                        <f:validateRegex pattern="[\w\.-]*[a-zA-Z0-9_].[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]" />
                                    </h:inputText>
                                    <h:message for="site" />
                                </div>
                            </div>
                        </h:form>

                        <h:form class="form-horizontal style-form" id="novoClienteCEP"  rendered="#{clienteController.existeCliente == false}">
                            <div class="form-group">
                                <h:outputLabel class="col-sm-2 col-sm-2 control-label" value="CEP" for="cep" />  
                                <div class="col-sm-10">
                                    <h:inputText  id="cep" value="#{clienteController.cep}" 
                                                  pt:placeholder="Somente Números" maxlength="8" required="true"
                                                  validatorMessage="Digite somente os Números"> 
                                        <f:validateRegex pattern="[0-9]+" />
                                        <f:validateLength minimum="8" maximum="8" />
                                    </h:inputText>
                                    <p:spacer width="55" height="10" />
                                    <h:commandButton  id="Buscar_Dados" value="Buscar Dados" 
                                                      actionListener="#{clienteController.buscarDadosCEP}" >
                                        <f:ajax execute="@form" render="novoClienteCEPDados"/>
                                    </h:commandButton>
                                </div>
                            </div>
                        </h:form>

                        <!--inicio autopreenchimento de endereço-->
                        <h:form class="form-horizontal style-form" id="novoClienteCEPDados" rendered="#{clienteController.existeCliente == false}">
                            <ui:repeat value="#{clienteController.enderecos}" var="dadosEndereco" >

                                <h:column >
                                    <div class="form-group">
                                        <h:outputLabel  value="Logradouro" class="col-sm-2 col-sm-2 control-label" />
                                        <div class="col-sm-10">
                                            <h:inputText value="#{dadosEndereco.tipoEndereco} #{dadosEndereco.logradouro}" 
                                                         class="form-control" disabled="true" />
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <h:outputLabel  value="Número" class="col-sm-2 col-sm-2 control-label" />
                                        <div class="col-sm-10">
                                            <h:inputText value="#{clienteController.numero}" class="form-control" disabled="false" 
                                                         pt:placeholder="Somente Números" required="true"
                                                         validatorMessage="Digite somente os Números">

                                                <f:validateLength minimum="1" />
                                            </h:inputText>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <h:outputLabel  value="Bairro" class="col-sm-2 col-sm-2 control-label" />
                                        <div class="col-sm-10">
                                            <h:inputText value="#{dadosEndereco.bairro}" class="form-control" disabled="true" />
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <h:outputLabel  value="Cidade" class="col-sm-2 col-sm-2 control-label" />
                                        <div class="col-sm-10">
                                            <h:inputText value="#{dadosEndereco.cidade}" class="form-control" disabled="true" />
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <h:outputLabel  value="Estado" class="col-sm-2 col-sm-2 control-label" />
                                        <div class="col-sm-10">
                                            <h:inputText value="#{dadosEndereco.UF}" class="form-control" disabled="true" />
                                        </div>
                                    </div>

                                </h:column>
                            </ui:repeat>
                        </h:form>

                        <!--fim auto preenchimeto endereco-->
                        <h:commandButton  id="Salvar" value="Salvar" action="#{clienteController.salvar}" >
                            <f:ajax execute="@all" render="@all"/>
                        </h:commandButton>
                        <p:spacer width="95" height="10" /> 
                        <h:commandButton value="Cancelar" type="reset"/> <p:spacer width="25" height="10"  />

                    </div>
                </div>
            </div>
            <!-- fim conteudo de novo cliente -->
        </ui:define>
    </ui:composition>
</h:body>

The form "dataClient" is coming null, someone knows why?

  • Have you debugged to check if the information name and nomefantasia client are populated in the object? If yes, these attributes have the get method inside the Client object?

  • I’ve debugged yes, and they come null, but if I nest the values come correct but I don’t want to nest form

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.