Fórum Problema no livro java para web #553023
03/05/2016
0
Davi Barros
Curtir tópico
+ 0Posts
03/05/2016
Marcos Paulo
Gostei + 0
03/05/2016
Davi Barros
Gostei + 0
03/05/2016
Marcos Paulo
Gostei + 0
03/05/2016
Janaina Mendes
Gostei + 0
03/05/2016
Janaina Mendes
Gostei + 0
03/05/2016
Davi Barros
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Cadastro de Usuários</title>
</h:head>
<h:body>
<h1>Cadastro de Usuários</h1>
<hr />
<h:form acceptcharset="UTF-8">
<h:messages />
<h:panelGrid columns="2">
<h:outputLabel value="Nome:" for="nome" />
<h:inputText id="nome" label="Nome" value="#{usuarioBean.nome}" required="true" />
<h:outputLabel value="e-Mail:" for="email" />
<h:inputText id="email" label="e-Mail" value="#{usuarioBean.email}" />
<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>
</html>
Página mostrausuario:
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<title>Usuário cadastrado</title>
</h:head>
<h:body>
<h1>Usuário cadastrado</h1>
<hr/>
Nome: <h:outputText value="#{usuarioBean.nome}"/> <br/>
e-Mail: <h:outputLink value="mailto:#{usuarioBean.email}">
<h:outputText value="#{usuarioBean.email}"/>
</h:outputLink><br/>
Senha: <h:outputText value="#{usuarioBean.senha}"/><br/>
<hr/>
<h:form>
<h:commandLink action="index" value="Início"/>
</h:form>
</h:body>
</html>
Classe java:
package br.com.javaparaweb.teste.web;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean(name="usuarioBean")
@RequestScoped
public class UsuarioBean {
private String nome;
private String email;
private String senha;
private String 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";
}
// FUTURO - salva o usuário
return "mostrausuario";
}
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; }
}
Erro na tela ao enviar o formulário:
usuario.xhtml @17,86 value="#{usuarioBean.nome}": Target Unreachable, identifier 'usuarioBean' resolved to null
Podem me ajudar?
Gostei + 0
03/05/2016
Davi Barros
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Cadastro de Usuários</title>
</h:head>
<h:body>
<h1>Cadastro de Usuários</h1>
<hr />
<h:form acceptcharset="UTF-8">
<h:messages />
<h:panelGrid columns="2">
<h:outputLabel value="Nome:" for="nome" />
<h:inputText id="nome" label="Nome" value="#{usuarioBean.nome}" required="true" />
<h:outputLabel value="e-Mail:" for="email" />
<h:inputText id="email" label="e-Mail" value="#{usuarioBean.email}" />
<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>
</html>
Página mostrausuario:
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<title>Usuário cadastrado</title>
</h:head>
<h:body>
<h1>Usuário cadastrado</h1>
<hr/>
Nome: <h:outputText value="#{usuarioBean.nome}"/> <br/>
e-Mail: <h:outputLink value="mailto:#{usuarioBean.email}">
<h:outputText value="#{usuarioBean.email}"/>
</h:outputLink><br/>
Senha: <h:outputText value="#{usuarioBean.senha}"/><br/>
<hr/>
<h:form>
<h:commandLink action="index" value="Início"/>
</h:form>
</h:body>
</html>
Classe java:
package br.com.javaparaweb.teste.web;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean(name="usuarioBean")
@RequestScoped
public class UsuarioBean {
private String nome;
private String email;
private String senha;
private String 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";
}
// FUTURO - salva o usuário
return "mostrausuario";
}
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; }
}
Erro na tela ao enviar o formulário:
usuario.xhtml @17,86 value="#{usuarioBean.nome}": Target Unreachable, identifier 'usuarioBean' resolved to null
Podem me ajudar?
Gostei + 0
03/05/2016
Marcos Paulo
Gostei + 0
03/05/2016
Marcos Paulo
Gostei + 0
03/05/2016
Davi Barros
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Cadastro de Usuários</title>
</h:head>
<h:body>
<h1>Cadastro de Usuários</h1>
<hr />
<h:form acceptcharset="UTF-8">
<h:messages />
<h:panelGrid columns="2">
<h:outputLabel value="Nome:" for="nome" />
<h:inputText id="nome" label="Nome" value="#{usuarioBean.nome}" required="true" />
<h:outputLabel value="e-Mail:" for="email" />
<h:inputText id="email" label="e-Mail" value="#{usuarioBean.email}" />
<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>
</html>
Página mostrausuario:
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<title>Usuário cadastrado</title>
</h:head>
<h:body>
<h1>Usuário cadastrado</h1>
<hr/>
Nome: <h:outputText value="#{usuarioBean.nome}"/> <br/>
e-Mail: <h:outputLink value="mailto:#{usuarioBean.email}">
<h:outputText value="#{usuarioBean.email}"/>
</h:outputLink><br/>
Senha: <h:outputText value="#{usuarioBean.senha}"/><br/>
<hr/>
<h:form>
<h:commandLink action="index" value="Início"/>
</h:form>
</h:body>
</html>
Classe java:
package br.com.javaparaweb.teste.web;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean(name="usuarioBean")
@RequestScoped
public class UsuarioBean {
private String nome;
private String email;
private String senha;
private String 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";
}
// FUTURO - salva o usuário
return "mostrausuario";
}
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; }
}
Erro na tela ao enviar o formulário:
usuario.xhtml @17,86 value="#{usuarioBean.nome}": Target Unreachable, identifier 'usuarioBean' resolved to null
Podem me ajudar?
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)