I have a login page, which I check if the user exist in my database, if so, the bean user
is initialized then I redirect to myprofile.xhtml
page, but there (in myprofile.xhtml
) I would like to catch the user values with another ManageBean
.
Just to don't mess with the resposabilities of each view and ManageBean.
UPDATE Follow BalusC approach:
@ManagedBean
@ViewScoped
public class Profile implements Serializable {
private static final long serialVersionUID = -5621841046523030920L;
@ManagedProperty("#{login.mUser}")
private User user;
// getter and setter
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
}
I would like to catch only the initialized object mUser (model).
You can inject beans in each other by @ManagedProperty
.
E.g.
@ManagedBean
@SessionScoped
public class UserManager userManager;
private User user;
// ...
}
and
@ManagedBean
@ViewScoped
public class Profile {
@ManagedProperty("#{userManager}")
private UserManager userManager;
// ...
}