The main idea is to put spring bean into JSF view scope,
that you can access from FacesContext.getCurrentInstance().getViewRoot().getViewMap()
This module provides appropriate Spring annotations for related JSF scopes:
- @SpringScopeRequest - for request scope
- @SpringScopeSession - for session scope
- @SpringScopeView - for view scope
For now this package is available only via https://jitpack.io/
repositories {
maven {
url "https://jitpack.io"
}
}
dependencies {
compile 'com.github.javaplugs:spring-jsf:0.1'
}
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<dependency>
<groupId>com.github.javaplugs</groupId>
<artifactId>spring-jsf</artifactId>
<version>0.1</version>
</dependency>
Just add next line to your applicationContext.xml
<import resource="classpath:/com/github/javaplugs/jsf/jsfSpringScope.xml"/>
In spring XML
<bean id="..." class="..." scope="view">
<!-- whatever -->
</bean>
From java
import com.github.javaplugs.jsf.SpringScopeView;
@SpringScopeView
@Component
class WhateverBean {
// Implementation
}