I have succesfully integrated JSF with Spring WebFlow & PrimeFaces, but injection by @ManagedProperty is always NULL during my web flow but using @Autowired annotation injection works. I would like to know why @ManagedProperty does not work but @Autowired works.
My enviroment: Spring 3.2.1.RELEASE, JSF 2.2.4, PrimeFaces 3.0.
UserBean class:
@ManagedBean
public class UserBean implements Serializable {
@ManagedProperty(value="#{messageBean}")
private MessageBean messageBean;
public MessageBean getMessageBean() {
return messageBean;
}
public void setMessageBean(MessageBean messageBean) {
this.messageBean = messageBean;
}
}
MessageBean class:
@ManagedBean(name = "messageBean")
public class MessageBean implements Serializable {
public String getMessage(){
return "Hello, " + name;
}
}
faces-config.xml:
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
webflow.xml:
<!-- Executes flows: the central entry point into the Spring Web Flow system -->
<flow-executor id="flowExecutor">
<flow-execution-listeners>
<listener ref="facesContextListener"/>
</flow-execution-listeners>
</flow-executor>
<!-- The registry of executable flow definitions -->
<flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices" base-path="/WEB-INF/flows">
<flow-location-pattern value="/**/flow.xml" />
<flow-location id="parent-flow" path="parent-flow.xml"/>
</flow-registry>
<!-- Configures the Spring Web Flow JSF integration -->
<faces:flow-builder-services id="flowBuilderServices" development="true" />
<!-- A listener to create and release a FacesContext -->
<beans:bean id="facesContextListener" class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener"/>
I have also file flow.xml and view.xhtml because I have integrated spring web flow with JSF using PrimeFaces.
WEB-INF/flows/ajax-jsf/flow.xml:
<var name="userBean" class="org.springframework.samples.webflow.ajax.UserBean" />
<var name="messageBean" class="org.springframework.samples.webflow.ajax.jsf.MessageBean" />
<view-state id="view">
<transition on="suggest" >
<evaluate expression="userBean.createEmailSuggestion(flowRequestContext)"
result="viewScope.emailSuggestion" />
</transition>
</view-state>
Do you know why my @ManagedProperty injection fails? If I replace @ManagedProperty with @Autowired I can see that object is created but @ManagedProperty is always null.