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 :)
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, eg: "BeanFactory" becomes mapped as "beanFactory", FooBean becomes "fooBean".
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.