HTML and CSS Reference
In-Depth Information
Chapter 2
JSF Under the Hood—Part 1
This chapter illustrates important topics in the JSF framework. In this chapter, you will learn in detail about the JSF
managed beans and the expression language (EL). You will also learn a bit about JSF navigation. Finally, you will learn
how to utilize the JSF exception handling mechanism in your JSF web applications for empowering the applications
error handling.
Managed Beans
The JSF managed bean is simply a POJO (Plain Old Java Object) that conforms to the JavaBeans naming conventions
and can be accessed from the JSF application (pages and other managed beans). It is called managed because it is
managed by the JSF framework which instantiates the bean class for you in a lazy manner when the JSF application
needs to use it. The next sections will cover in detail how to declare managed beans, how to initialize managed beans,
how to manage the dependencies between different managed beans, how to access managed beans, and finally how
to utilize the @Named and @inject annotations for working with the JSF POJO model.
Declaring Managed Beans
In the first chapter, we had an example of the managed beans usage in the firstApplication . Listing 2-1 shows the
User managed bean.
Listing 2-1. The User Managed Bean
package com.jsfprohtml5.firstapplication.model;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
public class User implements Serializable {
private String name;
private String password;
public String getName() {
return name;
Search WWH ::

Custom Search