Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>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?</p> <p>You probably have it as a service cause it has some additional features (probably transaction management) added by Spring, according to your configuration.</p> <p>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).</p> <p>So, when using JSF with Spring, you usually have two choices:</p> <ol> <li>Either you put the backing beans for the JSF pages in the JSF container, annotating them with <code>@ManagedBean</code>, <code>@RequestScoped</code>, <code>@ViewScoped</code>, etc; and injecting any necessary Spring bean with <code>@ManagedProperty</code> in a property (a setter is required)</li> <li>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 <code>@Component</code>, <code>@Scope("request")</code>, <code>@Scope("session")</code> and injecting with <code>@Autowired</code>, <code>@Qualifier</code> and the like.</li> </ol> <p>Personally, faced with that choice I'd go with the first choice, cause it gives you <code>@ViewScoped</code> and some other niceties. It's true it makes use of two IoC containers but then, which Java EE app does not?</p> <p>If you want to go the second route anyway, you may also <a href="http://cagataycivici.wordpress.com/2010/02/17/port-jsf-2-0s-viewscope-to-spring-3-0/">add a view scope for Spring beans, backed by JSF viewMap</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload