我需要将 Spring bean 注入 JSF(Primefaces)转换器。我尝试使用 EL 解析器注入 bean。但是,beannull
在转换器内部。
我的 JSF 转换器:
public class DepartmentConverter implements Converter {
private DepartmentService departmentService;
//getter setter for this property
@Override
public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
//codes
}
@Override
public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {
//Codes
}
}
faces-config.xml
:
<converter>
<converter-id>DepartmentConverter</converter-id>
<converter-class>com.studinfo.jsf.converter.DepartmentConverter</converter-class>
<property>
<property-name>departmentService</property-name>
<property-class>com.studinfo.services.DepartmentService</property-class>
<default-value>#{DepartmentService}</default-value>
</property>
</converter>
EL解析器:
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
当我调试我的代码时,departmentService
属性是null
. 我可以以同样的方式访问托管 JSF bean 中的 Spring bean。