1
I have a login form with the registration and password fields. I am trying to validate this login where only the number "92018" can log in to the system, but when the login method is called, it does not pass by if, even having typed the correct value, I already put a breakpoint to see if the value would be different, but it is not. What could be?
Managedbean
public String Logar()
{
if(associado.getMatricula()=="92018")
{
return "/Teste";
}
return"/sucesso";
}
Login form
<h:form id="formLogin">
<p:fieldset legend="Insira os dados de acesso"
style="margin-bottom:20px">
<p:outputLabel for="matricula" value="Matricula: " />
<br />
<p:inputText id="matricula" value="#{LoginBean.associado.matricula}"
required="true" autocomplete="off" />
<br />
<p:outputLabel for="senha" value="Senha: " />
<br />
<p:inputText id="senha" value="#{LoginBean.associado.senha}"
required="true" />
<br />
<br />
<p:commandButton value="Entrar" id="logar"
action="#{LoginBean.Logar}" ajax="false" />
<br />
</p:fieldset>
</h:form>
Class
public class Associado {
private String matricula,senha;
public String getMatricula() {
return matricula;
}
public void setMatricula(String matricula) {
this.matricula = matricula;
}
public String getSenha() {
return senha;
}
public void setSenha(String senha) {
this.senha = senha;
}
}
It worked! Thanks! I started studying java yesterday and I didn’t know this detail.
– Ryan Santos