Estou com problema na hora de fazer o binding, quando eu submeto o formulário, os campos estão nulos.
:(
<!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:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Bem-vindo</title>
</h:head>
<h:body>
<h:form>
<p:panelGrid columns="1">
<p:outputLabel value="Nome: " />
<p:inputText value="#{usuarioBean.usuario.name}" />
<p:outputLabel value="Usuário: " />
<p:inputText value="#{usuarioBean.usuario.user}" />
<p:outputLabel value="Senha: " />
<p:password value="#{usuarioBean.usuario.pass}"/>
<p:commandButton value="Vamos lá!" action="#{usuarioBean.ok}" />
</p:panelGrid>
</h:form>
</h:body>
</html>
@Named
@RequestScoped
public class UsuarioBean {
private Usuario usuario = new Usuario();
public Usuario getUsuario(){
return this.usuario;
}
public void ok(){
System.out.println("Nome: " + usuario.getName());
System.out.println("Usuario: " + usuario.getUser());
System.out.println("Senha: " + usuario.getPass());
}
}
@Entity
public class Usuario {
@Id @GeneratedValue
private long id;
private String name;
private String user;
private String pass;
public Usuario(){}
public long getId() {
return id;
}
public String getName() {
return name;
}
public String getUser() {
return user;
}
public String getPass() {
return pass;
}
public void setId(long id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public void setUser(String user) {
this.user = user;
}
public void setPass(String pass) {
this.pass = pass;
}
}