I'm trying to inject entire JSF managed bean into another managed bean by means of @ManagedProperty
annotation (very similar to Possible to inject @ManagedBean as a @ManagedProperty into @WebServlet?, but I'm injecting into a bean, not a servlet). This is what I'm doing:
@ManagedBean
public class Foo {
@ManagedProperty(value = "#{bar}")
private Bar bar;
}
@ManagedBean
public class Bar {
}
Doesn't work (JSF 2.0/Mojarra 2.0.3):
SEVERE: JSF will be unable to create managed bean foo when it is
requested. The following problems where found:
- Property bar for managed bean foo does not exist. Check that
appropriate getter and/or setter methods exist.
Is it possible at all or I need to do this injection programmatically via FacesContext
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…