I think you may be confused by the word "bean".
The thing is, the "service" you are talking about is also a Spring bean, right?
You probably have it as a service cause it has some additional features (probably transaction management) added by Spring, according to your configuration.
The JSF IoC container is very simplistic, it does not allow you to configure its lifecycle to include transaction management, AOP and things like that. Those things you have to do with Spring (or EJB, in a Java EE environment).
So, when using JSF with Spring, you usually have two choices:
- Either you put the backing beans for the JSF pages in the JSF container, annotating them with
@ManagedBean
, @RequestScoped
, @ViewScoped
, etc; and injecting any necessary Spring bean with @ManagedProperty
in a property (a setter is required)
- Or skip the JSF container and put the backing beans along with all others in the Spring container, and use the Spring scopes of request/session, annotating them with Spring's annotations
@Component
, @Scope("request")
, @Scope("session")
and injecting with @Autowired
, @Qualifier
and the like.
Personally, faced with that choice I'd go with the first choice, cause it gives you @ViewScoped
and some other niceties. It's true it makes use of two IoC containers but then, which Java EE app does not?
If you want to go the second route anyway, you may also add a view scope for Spring beans, backed by JSF viewMap.