Estou tentando realizar um cadastro utilizando o primefaces, a minha duvida eh quando o usuario clicar em enviar
ocorrera o envio dos dados porem observei que os atributos do bean nao estao sendo setados… alguem sabe como fazer para setar os atributos, da forma como esta abaixo nao seta… ficam nulos…
Pagina jsf
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.prime.com.tr/ui">
<h:head>
</h:head>
<h:body>
<h1>Teste</h1>
<h:form>
<p:panel header="Cadastro de Usuário">
<h:panelGrid columns="2" cellpadding="5">
<h:outputText value="Login: " />
<p:keyboard value="#{usuarioBean.login}" />
<h:outputText value="Senha: " />
<p:password value="#{usuarioBean.senha}"
password="true" feedback="true" required="true" />
<h:outputText value="Email: " />
<p:keyboard value="#{usuarioBean.email}" />
<h:outputText value="Nome Completo: " />
<p:keyboard value="#{usuarioBean.nome}" />
<h:outputText value="Endereco: " />
<p:keyboard value="#{usuarioBean.endereco}" />
<h:outputText value="Data de Nascimento: " />
<p:inputMask value="#{usuarioBean.dataNascimento}" mask="99/99/9999" />
<h:outputText value="Telefone: " />
<p:inputMask value="#{usuarioBean.telefone}" mask="(99) 999-9999" />
<p:commandButton value="Limpar" type="reset" />
<p:commandButton value="Enviar" action="#{usuarioBean.salvar}"
type="Submit" />
</h:panelGrid>
</p:panel>
</h:form>
</h:body>
</html>
UsuarioBean
package bean;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
@SessionScoped
@ManagedBean
@Entity
@Table (name="usuario")
public class UsuarioBean {
@Column(name="id")
private Long id;
@Column(name="login")
private String login;
@Column(name="senha")
private String senha;
@Column(name="nome")
private String nome;
@Column(name="email")
private String email;
@Column(name="endereco")
private String endereco;
@Column(name="dataNascimento")
private String dataNascimento;
@Column(name="telefone")
private String telefone;
@Transient
private UsuarioBean usuario;
public UsuarioBean() {}
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
public Long getId() {
return id;
}
public void salvar(){
System.out.print(getNome());
}
public UsuarioBean getUsuario() {
return usuario;
}
public void setUsuario(UsuarioBean usuario) {
this.usuario = usuario;
}
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public String getSenha() {
return senha;
}
public void setSenha(String senha) {
this.senha = senha;
}
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 getEndereco() {
return endereco;
}
public void setEndereco(String endereco) {
this.endereco = endereco;
}
public String getDataNascimento() {
return dataNascimento;
}
public void setDataNascimento(String dataNascimento) {
this.dataNascimento = dataNascimento;
}
public String getTelefone() {
return telefone;
}
public void setTelefone(String telefone) {
this.telefone = telefone;
}
public void setId(Long id) {
this.id = id;
}
}