title: ManagedProperty not working
body: <p>I have problem with JSF 2 property binding and honestly I hit a wall here..</p>
  
  <p>What I want to accomplish is this: a request-scoped bean (loginBean) process login action and stores username in the session-scoped bean (userBean). I want to inject userBean into loginBean via @ManagedProperty, but when loginBean.doLoginAction is called, userBean is set to null.</p>
  
  <p>Here is the code:</p>
  
  <p>UserBean class</p>
  
  <pre><code>import javax.faces.bean.ManagedBean;
  import javax.faces.bean.SessionScoped;
  
  @ManagedBean
  @SessionScoped
  public class UserBean {
  
  private String username;
  
  public String getUsername() {
      return username;
  }
  
  public void setUsername(String username) {
      this.username = username;
  }
  
  public boolean isLogged() {
      if (username != null)
          return true;
      return false;
  }
  }
  </code></pre>
  
  <p>loginBean class:</p>
  
  <pre><code>import javax.faces.bean.ManagedBean;
  import javax.faces.bean.ManagedProperty;
  import javax.faces.bean.RequestScoped;
  
  @ManagedBean
  @RequestScoped
  public class LoginBean {
  
  @ManagedProperty(value = "userBean")
  private UserBean userBean;
  
  private String name;
  private String password;    
  
  public String getName() {
      return name;
  }
  
  public void setName(String name) {
      this.name = name;
  }
  
  public String getPassword() {
      return password;
  }
  
  public void setPassword(String password) {
      this.password = password;
  }
  
  public UserBean getUserBean() {
      return userBean;
  }
  
  public void setUserBean(UserBean userBean) {
      this.userBean = userBean;
  }
  
  public String doLoginAction() {
      if (name.equals("kamil") &amp;&amp; password.equals("kamil")) {
          userBean.setUsername(name);
      }
      return null;
  }
  
  public String doLogoutAction() {
      return null;
  }
  }           
  </code></pre>
  
  <p>Any ideas what I'm doing wrong here?</p>