Toda vez que tento fazer login, meu usuário esta vindo vazio da tela, ja debugguei e não achei o erro
package br.com.caelum.livraria.bean;
import java.io.Serializable;
import javax.faces.application.FacesMessage;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;
import br.com.caelum.livraria.dao.UsuarioDao;
import br.com.caelum.livraria.modelo.Usuario;
@RequestScoped
@Named
public class LoginBean implements Serializable {
private static final long serialVersionUID = 1L;
private Usuario usuario= new Usuario();
private UsuarioDao usuarioDao;
@Inject
public LoginBean(UsuarioDao usuarioDao){
this.usuarioDao= usuarioDao;
}
public String efetuaLogin() {
System.out.println("fazendo login do usuario "+ usuario.getEmail());
FacesContext context = FacesContext.getCurrentInstance();
boolean existe = usuarioDao.existe(this.usuario);
if(existe ) {
context.getExternalContext().getSessionMap().put("usuarioLogado", this.usuario);
return "livro?faces-redirect=true";
}
context.getExternalContext().getFlash().setKeepMessages(true);
context.addMessage(null, new FacesMessage("Usuário não encontrado"));
return "login?faces-redirect=true";
}
public String deslogar() {
FacesContext context = FacesContext.getCurrentInstance();
context.getExternalContext().getSessionMap().remove("usuarioLogado");
return "login?faces-redirect=true";
}
public Usuario getUsuario() {
return usuario;
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!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://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:composition template="_template.xhtml">
<ui:define name="titulo">
<p:outputPanel>Login</p:outputPanel>
</ui:define>
<ui:define name="conteudo">
<p:messages globalOnly="true" />
<h:form id="login">
<p:fieldset legend="Login">
<h:panelGrid columns="3">
<p:outputLabel value="Email:" for="email" />
<p:inputText id="email" value="#{loginBean.usuario.email}" required="true">
<f:passThroughAttribute name="type" value="email" />
</p:inputText>
<p:message for="email" id="messageEmail" />
<p:outputLabel value="Senha:" for="senha" />
<p:password id="senha" value="#{loginBean.usuario.senha}" feedback="true" required="true" />
<p:message for="senha" id="messageSenha" />
<p:commandButton value="Efetue Login" action="#{loginBean.efetuaLogin}" update="@form" process="@form" />
</h:panelGrid>
</p:fieldset>
</h:form>
</ui:define>
</ui:composition>
</html>