1
I’m starting to create a web application using JSF, but I try to insert some data through a form and it displays the error below:
/usuario.xhtml @19,72 value="#{usuarioBean.email}": Target Unreachable, Identifier 'usuarioBean' resolved to null
My save method:
public String salvar(){
FacesContext context = FacesContext.getCurrentInstance();
if(!this.senha.equalsIgnoreCase(this.confirmaSenha)){
context.addMessage(null,new FacesMessage(FacesMessage.SEVERITY_ERROR,"Senha confirmada incorretamente",""));
return "usuario";
}
//salva usuario
return "sucesso";
}
Xhtml page
Registration of Users
Registration of Users
<h:outputLabel value="e-Mail:" for="email" />
<h:inputText id="email" label="email" value="#{usuarioBean.email}" />
<h:outputLabel value="CPF:" for="cpf" />
<h:inputText id="cpf" label="cpf" value="#{usuarioBean.cpf}" />
<h:outputLabel value="Senha:" for="senha" />
<h:inputSecret id="senha" label="Senha" value="#{usuarioBean.senha}" required="true"/>
<h:outputLabel value="Confirmar Senha:" for="confirmarsenha" />
<h:inputSecret id="confirmarSenha" label="Confirmar Senha" value="#{usuarioBean.confirmaSenha}" required="true" />
<h:outputText/>
<h:commandButton action="#{usuarioBean.salvar}" value="Salvar" />
</h:panelGrid>
</h:form>
<hr />
</h:body>
My Bean Class:
@Managedbean(name="User") @Requestscoped public class Usuariobean {
private String nome;
private String cpf;
private String senha;
private String confirmaSenha;
@ManagedProperty(value="#{param}")
private Map<String,String> parametros;
//Método de Operação
public String operacao(){
//executa a operação
return "resultado";
}
public String novo(){
return "usuario";
}
//Getters e Setters
public void setNome(String nome) {
this.nome = nome;
}
public String getNome() {
return nome;
}
public String getCpf() {
return cpf;
}
public void setEmail(String cpf) {
this.cpf= cpf;
}
public String getSenha() {
return senha;
}
public void setSenha(String senha) {
this.senha = senha;
}
public String getConfirmaSenha() {
return confirmaSenha;
}
public void setConfirmaSenha(String confirmaSenha) {
this.confirmaSenha = confirmaSenha;
}
public String salvar(){
FacesContext context = FacesContext.getCurrentInstance();
if(!this.senha.equalsIgnoreCase(this.confirmaSenha)){
context.addMessage(null,new FacesMessage(FacesMessage.SEVERITY_ERROR,"Senha confirmada incorretamente",""));
return "usuario";
}
//salva usuario
return "sucesso";
}
}
Lib:
Someone can help me?
Next time I’ll do it with text. Thanks for the brother help.
– Felipe Januário
Uses CDI bean, JSF bean ? created get/set for properties ? leverages and puts all manageBean.
– Dilnei Cunha
Dilnei, use JSF bean
– Felipe Januário
Use Maven? or add libs to the app’s classpath? can you add the information? @Request Scope comes from this import?
import javax.faces.bean.RequestScoped;

– Dilnei Cunha
Dilnei, I don’t use Maven. I added libs to the classpath. I added lib img to the question. ’s annotation comes from this import: import javax.faces.bean.Requestscoped;
– Felipe Januário
Worse than I’m not even able to debug, to check if he’s getting into the method. I’m a beginner, and I’m developing this application through an example from the book.
– Felipe Januário
Sorry so many questions but if necessary, you have configured web.xml? and created the faces, faces-config.xml configuration file?
– Dilnei Cunha