I\'ve some trouble with injecting one managedbean in another by defining a managedproperty. I\'m googling and stackoverflowing now for 3 days, but with no result...
Your JSF backing beans (MainBean
and UserBean
) should be managed either by JSF or by Spring, but not by both of them.
If your beans are managed by JSF:
@ManagedBean
and @...Scoped
applicationContext.xml
You use @ManagedProperty
instead of @Autowired
, even if you need to inject beans managed by Spring (don't forget setters, @ManagedProperty
requires it):
@ManagedProperty("#{userDao}")
private UserDao userDao;
If your beans are managed by Spring:
applicationContext.xml
with appropriate scopes (view scope is not supported)@ManagedBean
and @...Scoped
@Autowired
instead of @ManagedProperty
and you cannot inject beans managed by JSF this wayIn both cases you need to configure Spring-JSF bridge in faces-context.xml
:
<application>
<el-resolver>
org.springframework.web.jsf.el.SpringBeanFacesELResolver
</el-resolver>
</application>