Answer the question
In order to leave comments, you need to log in
How can I call a bean method from another bean?
I have 2 beans navigation and user
How can I access the user bean method from the navigation bean ?
@Named("navigation")
@SessionScoped
public class NavigationController implements Serializable {
private String outcome = null;
@ManagedProperty(value = "#{user}")
private UserBean userBean; // <-- тут держу ссылку на бин User
public void setUserBean(UserBean userBean) {
this.userBean = userBean;
}
.....
public void handleMouseClick(ActionEvent e) {
userBean.metod(); // <--- Тут хочу вызвать метод у бина
}
}
@Named("user")
@SessionScoped
public class UserBean implements Serializable {
private Boolean success;
public Boolean getSuccess() {
return success;
}
public void metod() {
success = false;
}
}
Answer the question
In order to leave comments, you need to log in
where is DI?
the presence of a setter does not guarantee anything in this regard
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question