I would like to use jsf annotations and some spring
annotations to inject a spring bean/service into a jsf managed bean.
(on the jsf bean i only want to use jsf annotations)
I dont want to use annotations like @named
/ @inject
.
I have tried to find a solution on the net but without any luck.
Example
@ManagedBean
@ViewScoped
public class MyBean {
@ManagedProperty(value = "#{mySpringBean}")
private MySpringBean mySpringBean;
public void setMySpringBean(MySpringBean mySpringBean) {
this.mySpringBean = mySpringBean;
}
public void doSomething() {
//do something with mySpringBean
}
}
Is something like this possible without the use of xml. For example, I would NOT like to use something like
FacesContextUtils.getWebApplicationContext(context).getBean("MySpringBean");
or in faces-config.xml
<managed-bean>
<managed-bean-name>myBean</managed-bean-name>
<managed-bean-class>com.mytest.MyBean</managed-bean-class>
<managed-bean-scope>view</managed-bean-scope>
<managed-property>
<property-name>mySpringBean</property-name>
<value>#{mySpringBean}</value>
</managed-property>
</managed-bean>
Is something like the above possible with annotations and without defining all the jsf beans/properties and the spring beans/properties for every bean in the config xml files?
applicationContext.xml
as well. The Spring EL resolver does not seem to work with ViewScoped beans that I have noticed. Try changing this to SessionScoped and see if the property becomes injected. – maple_shaft