1
I’m starting web development with java and I’m doing some tests and I came across the following situation, I created a form that loads a list based on every click of the button, however, when I refresh the page I still load the list with the last object that was inserted in the list. Do you understand? If so, why does this happen?
EDIT Codes.
Method that performs student insertion in a list.
public void incluirAluno(){
this.listaAlunos.add(aluno);
System.out.println("Aluno: "+aluno.getNome()+" foi adicionado com sucesso!");
this.aluno = new Aluno();
}
View
<h:form>
<p:fieldset legend="Formulário de Cadastro de Clientes" toggleable="true" toggleSpeed="500">
<b>Nome Completo </b><br/>
<p:inputText value="#{controllerAluno.aluno.nome}" placeholder="Digite seu Nome Aqui" style="width:30%"/>
<p></p>
<b>Data de Nascimento</b> <br/>
<p:calendar id="effect" value="#{controllerAluno.aluno.data_Nascimento}" effect="fold" placeholder="10/10/2010"/>
<p></p>
<b>Sexo</b><br/>
<p:selectOneMenu id="console" value="#{controllerAluno.aluno.sexo}" style="width:125px">
<f:selectItem itemLabel="Masculino" itemValue="Masculino" />
<f:selectItem itemLabel="Feminino" itemValue="Feminino" />
<f:selectItem itemLabel="Indiferente" itemValue="Indiferente" />
</p:selectOneMenu>
<p></p>
<h:commandButton value="Incluir" action="#{controllerAluno.incluirAluno}"/>
<p></p>
</p:fieldset>
</h:form>
Add code snippets containing the methods involved, as well as your view.
– Marcos Sousa