Reputation: 138
When I need a BeanFactory in a bean managed by Spring, I use:
private @Autowired BeanFactory factory;
How can I achive this in a Managed Bean? I have tried:
@ManagedProperty(value = "#{BeanFactory}")
private BeanFactory beanFactory;// (the property has getters and setters)
But the property is null.
I have an EL resolver in faces-config:
<el-resolver>
org.springframework.web.jsf.el.SpringBeanFacesELResolver
</el-resolver>
Thank you and sorry for my poor english :)
Upvotes: 0
Views: 537
Reputation: 26
It appears that your @ManagedProperty
markup may have been the problem, in that (value = "#{BeanFactory}")
should have been (value = "#{beanFactory}")
, unless your BeanFactory class was specifically named "BeanFactory" in the @ManagedBean markup within it.
By default, beans annotated with @ManagedBean will be mapped to their class name, but the first character will be lower case, e.g.: "BeanFactory" becomes mapped as "beanFactory", FooBean becomes "fooBean".
Upvotes: 1