I have a Session scoped bean
import javax.faces.bean.SessionScoped;
import javax.inject.Named;
@Named
@SessionScoped
public class SessionBean implements Serializable{
I inyect the object in one Filter...
public class FiltroSeguridad implements Filter{
@Inject
private SessionBean sessionBean;
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
sessionBean.setRutaRedirect(httpRequest.getRequestURI());
}
}
But, I inyect SessionBean in the next interaction...
@Model
public class CuentaUsuarioWebBean implements Serializable{
@Inject
private SessionBean sessionBean;
public void loginUsuario() throws IOException{
sessionBean.getRutaRedirect();
}
}
But the property getRutaRedirect()
returns null
I change the import by CDI annotations it still doesn't work (javax.enterprise.context.SessionScoped
), same with JSF annotation (javax.faces.bean.ManagedBean
and @ManagedProperty
).
Thanks.
PD: Sorry for my English!
/WEB-INF/beans.xml
file (which a bit sane IDE would already autogenerate when you choose the CDI facet and/or which is already mentioned in a bit sane CDI tutorial, if you've read a tutorial). Do you have this file?