The Spring framework (http://springframework.org) is a well-established and well-respected framework for dependency injection.

The JSF "managed beans" facility is a very simple implementation of the same sort of thing, but is missing a large number of Spring features.

JSF can be configured to use Spring to manage beans, and this integration works very well, with absolutely no changes needed in the rest of a JSF application. Spring's power can add a lot of flexibility to developing JSF applications.

Spring version 1.x did not have the ability to declare objects as having request or session scope, so could not be used as a complete replacement for the JSF "managed beans" facility. Spring could be used to inject data into managed beans, but the "top level" beans had to be declared in the faces-config files.

However Spring 2.x does support request and session scopes, and so can be used as a complete replacement for JSF managed bean declarations.

There are several excellent tutorials on this written by Cagatay Civici:

Spring provides its own documentation on this topic:

This project may also be of interest:

There is a rather old and obsolete page on this topic here:

A demo application, that shows Spring, Orchestra and JSF can be found here:

JSF_With_Spring (last edited 2009-09-20 23:00:52 by localhost)