Pro JSF and Ajax



Model
With JSF, the concept of a managed bean has been introduced. The managed bean is the glue
to the application logic--backing code or backing bean. Managed beans are defined in the
faces-config.xml

file and give the application developer full access to all the mapped backing
bean's methods. This concept of IoC is successfully used in frameworks such as Spring, Hive-
Mind, and Oracle ADF model binding (JSR-227). The managed bean facility is responsible for
creating the backing beans or other beans such as Data Access Objects (DAO). In JSF, a back-
ing bean is a plain old Java object (POJO) with no dependency on implementation-specific
interfaces or classes. The aforementioned JSF controller--the FacesServlet--is not aware of
what action has been taken; it is aware only of the outcome of a particular action and will use
that outcome to decide where to navigate. In JSF it is the component that is aware of which
action, or method, to call on a particular user event. Code Sample 1-2 shows a managed bean
defined in the faces-config.xml file.

Code Sample 1-2.
Managed Bean Defined in the faces-config.xml File
<managed-bean>
<managed-bean-name>sample</managed-bean-name>
<managed-bean-class>

com.apress.projsf.ch1.application.SampleBean
</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>

</managed-bean>
C H A P T E R 1
s
T H E F O U N D AT I O N O F J S F : C O M P O N E N T S
11