Inputtext returns null

Asked

Viewed 225 times

1

I got a problem I don’t know what else to do. My idea was to have a Checkbox that when marking would show a field and when unchecking would hide this field, for that I used rendered and ajax, However when I mark this Checkbox even if I write something in the input that shows the value sent is always null. Can you help me?

.XHTML

<h:panelGroup>
                    <b><h:outputText value="Possui Deficiência? " /></b>
                    <p:selectBooleanCheckbox
                        value="#{controllerAluno.alunoCadastrar.deficiente}"
                        id="checkDeficiencia" immediate="true">
                            <p:ajax event="change" update="campoEspecifique" />
                    </p:selectBooleanCheckbox>
                </h:panelGroup>
                <br />
                <h:panelGroup id="campoEspecifique">
                    <b><p:outputLabel value="Especifique:"
                            rendered="#{controllerAluno.alunoCadastrar.deficiente}"/> </b>
                    <p:inputText
                        rendered="#{controllerAluno.alunoCadastrar.deficiente}"                         
                        value="#{controllerAluno.alunoCadastrar.deficiencia}"/>                         
                </h:panelGroup>

Mbean

public void inserir() throws Exception
{

    System.out.println("É Deficiente? " + this.alunoCadastrar.isDeficiente());
    System.out.println("Qual? " + this.alunoCadastrar.getDeficiencia());
    System.out.println("ID? " + this.alunoCadastrar.getId());
    System.out.println("Nome? " + this.alunoCadastrar.getNome());
    System.out.println("Sexo? " + this.alunoCadastrar.getSexo());
    System.out.println("Data? " + this.alunoCadastrar.getData_Nascimento());
    System.out.println("Turma? " + this.alunoCadastrar.getTurma().getDescricao());
    AdicionarMensagem.retornaInfo("Aluno Adicionado com Sucesso!");
    this.alunoCadastrar = new Aluno();
    AlunoNegocio an = new AlunoNegocio();               
    if (an.inserir(this.alunoCadastrar)) {
        AdicionarMensagem.retornaInfo("Aluno Adicionado com Sucesso!");
        this.alunoCadastrar = new Aluno();
    }   
}

This is what generates, however I have reported a value in disability and always goes null as I said earlier.

inserir a descrição da imagem aqui

  • Some questions: You really need the attribute immediate=true at checkbox ? When you are submitting your form, you are using process at something ?

  • Show in xhtml the component that sends the form.

2 answers

0

Try to put it like that in your ajax:

 <p:ajax partialSubmit="true" .... />

0

In your ajax put the immediate:

<p:ajax event="change" update="campoEspecifique" immediate="true"/>

Browser other questions tagged

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