JSF does not populate @Named @RequestScoped bean with submitted input values

From your bean:

import javax.faces.bean.RequestScoped;
import javax.inject.Named;

@Named("loginRequest")
@RequestScoped
public class LoginRequest {

You’re mixing CDI and JSF annotations. You can and should not do that. Use the one or the other. I don’t know what’s the book is telling you, but most likely you have chosen the wrong autocomplete suggestion during the import of the @RequestScoped annotation. Please pay attention to if whatever the IDE suggests you matches whatever the book tells you.

So, you should be using either CDI annotations only

import javax.enterprise.context.RequestScoped;
import javax.inject.Named;

@Named("loginRequest")
@RequestScoped
public class LoginRequest {

or JSF annotations only

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

@ManagedBean(name="loginRequest")
@RequestScoped
public class LoginRequest {

Otherwise the scope defaults to "none" and every single EL expression referring the bean would create a brand new and separate instance of the bean. With three EL expressions referring to #{loginRequest} you would end up with 3 instances. One where name is been set, one where password is been set and one where action is been invoked.


Unrelated to the concrete problem, the managed bean name already defaults to the classname with 1st character lowercased conform Javabean specification. You could just omit the ("loginRequest") part altogether.

Leave a Comment