Pessoal, to estudando JavaEE com o livro java para web que acabei de comprar.
Em um dos primeiros exemplos, está ocorrendo um erro:
/usuario.xhtml @18,21 value="#{usuarioBean.nome}": Target Unreachable, identifier 'usuarioBean' resolved to null
Segue a classe e o faceConfig
UsuarioBean.classpackage financeiro.web;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
public class UsuarioBean {
private String nome;
private String email;
private String senha;
private String confirmaSenha;
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
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 novo(){
return "usuario";
}
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";
}
return "sucesso";
}
}
<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="2.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
<!-- Bean Usuário -->
<managed-bean>
<managed-bean-name>usuarioBean</managed-bean-name>
<managed-bean-class>financeiro.web.UsuarioBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<!--
<managed-property>
<property-name>origemCadastro</property-name>
<value>internet</value>
</managed-property>
<managed-property>
<property-name>relacaoConhecimento</property-name>
<value>#{comoConheceuOSite}</value>
</managed-property>
<managed-property>
<property-name>endereco</property-name>
<null-value/>
</managed-property>
-->
</managed-bean>
<!-- Bean ComoConheceuOSite -->
<managed-bean>
<managed-bean-name>comoConheceuOSiteMap</managed-bean-name>
<managed-bean-class>java.util.HashMap</managed-bean-class>
<managed-bean-scope>none</managed-bean-scope>
<map-entries>
<map-entry><key>B</key><value>Blogs</value></map-entry>
<map-entry><key>R</key><value>Revistas</value></map-entry>
<map-entry><key>A</key><value>Amigos</value></map-entry>
<map-entry><key>F</key><value>Ferramentas de Buscas</value></map-entry>
</map-entries>
</managed-bean>
<managed-bean>
<managed-bean-name>cidadeList</managed-bean-name>
<managed-bean-class>java.util.ArrayList</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<list-entries>
<value>Joinville</value>
<value>São Paulo</value>
<value>Rio de Janeiro</value>
<value>Brasília</value>
</list-entries>
</managed-bean>
</faces-config>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Cadastro de Usuário</title>
</head>
<body>
<h1>Cadastro de Usuário</h1>
<hr />
<h:form>
<h:messages></h:messages>
<h:panelGrid columns="2">
<h:outputLabel value="Nome" for="nome"></h:outputLabel>
<h:inputText id="nome" label="Nome" value="#{usuarioBean.nome}"
required="true"></h:inputText>
<h:outputLabel value="E-Mail" for="email"></h:outputLabel>
<h:inputText id="email" value="#{usuarioBean.email}" label="email" />
<h:outputFormat value="Senha" for="senha" />
<h:inputSecret value="#{usuarioBean.senha}" id="senha" label="senha"
required="true"></h:inputSecret>
<h:outputLabel value="Confirmar Senha" for="confirmarsenha"></h:outputLabel>
<h:inputSecret id="confirmarsenha" label="Confirmar Senha"
required="true" value="#{usuarioBean.comfirmaSenha}"></h:inputSecret>
<h:outputText></h:outputText>
<h:commandButton value="Salvar" action="#{usuarioBean.salvar}" />
</h:panelGrid>
</h:form>
<hr />
</body>
</html>
Aguardo resposta... Obrigado...