Hey guys,
I have a basic question about JSF and their ManagedBeans. Imagine we have set a ManagedBean that only contains data for and from my view:
@ManagedBean(name = "dataBean")
@SessionScoped
public class DataBean {
Next here is my controller with a dependency injection to connect controller with model:
@ManagedBean
@RequestScoped
public class Controller {
@ManagedProperty(value = "#{dataBean}")
private DataBean dataBean;
Now let's think about several managedBeans in one controller: Is it possible to inject another ManagedBean to the controller like:
@ManagedProperty(value = "#{dataBean}")
private DataBean dataBean;
@ManagedProperty(value = "#{dataBean}")
private DataBean dataBean2;
And if so, how does JSF know what bean belongs to what .xhtml page?
I am very confused at the moment :-/ Because there is something wrong with my code... But first I should understand it clearly
Cheers...
Addition:
Let's say I want to access the same managedBean (sessionScoped) out of two controllers. Can I easy say:
@ManagedBean
@RequestScoped
public class Controller {
@ManagedProperty(value = "#{dataBean}")
private DataBean dataBean;
...
@ManagedBean
@RequestScoped
public class Controller2 {
@ManagedProperty(value = "#{dataBean}")
private DataBean dataBean;
And I have the same instance of DataBean?