Reputation: 27455
I'm using the following spring's jars:
spring-web-2.5.5.jar
spring-context-2.5.5.jar
spring-core-2.5.5.jar
spring-orm-2.5.5.jar
spring-support-2.0.8.jar
spring-security-taglibs-2.0.3.jar
spring-security-acl-2.0.3.jar
spring-security-core-2.0.4.jar
spring-aop-2.5.5.jar
spring-jdbc-2.5.5.jar
spring-tx-2.5.5.jar
The issue is after migration from JSF 1.2
to JSF 2.0
beans, defined in the faces-context cannot be injected into a managed bean with session scope. For instance:
<managed-bean>
<managed-bean-name>bannersController</managed-bean-name>
<managed-bean-class>jaxp.com.controller.BannersController</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>bannerDao</property-name>
<value>#{bannerDao}</value>
</managed-property>
</managed-bean>
and
<bean id="bannerDao" class="jaxp.com.db.dao.BannerDaoImpl"
scope="prototype">
<property name="sessionFactory" ref="sitePartnerSessionFactory" />
<property name="dataSource" ref="sitePartnerDataSource" />
</bean>
When I replace the scope of the bean to session it'll work fine. But now, the managed property is just null. It had worked before we migrated to JSF 2.0. What's wrong and how to fix?
UPD: If I set managed bean scope to view scope it also works fine/
Upvotes: 0
Views: 191
Reputation: 2063
JSF bean:
inject spring service
@ManagedProperty("#{handlerService}")
private HandlerService handlerService = null;
///add setter
Spring service:
@Service("handlerService")
@Component
public class HandlerService {
@Autowired
private DomainService domainService;
faces-config.xml
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
------------
web.xml
<context-param>
<param-name>contextClass</param-name>
<param-value>
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>com.myspringconfgigclass.CommonCoreConfig</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
Upvotes: 1