JSF 2.0 learning notes

1. Using CDI bean.

In JSF 2.0 CDI (Context and Dependency Injection) is recommended, because that the JSF managed beans are fairly limited, meanwhile CDI is more flexiable.

We declare CDI bean by using @Named("beanname") annotation. We also need to define the scope of this bean, for example @SessionScoped.
Here the @SessionScoped annottion is from the javax.enterprise.context, but not the javax.faces.bean package.

CDI beans must implement the Serializable interface.

We also need to include a file WEB-INF/beans.xml to active CDI beans processing. This file can be empty.

2. Expression Language Syntax

Value expression do not work for indexed properties. For example, p is an indexed property of a bean b and i is an integer, then b.p[i] does not access the ith value of the property.

Indexed properties are specified by the following methods:
//Methods to access individual values
        public PropertyElement getPropertyName(int index)
public void setPropertyName(int index, PropertyElement element)

3. The Initial Term (for example, a.b.c.d, then a is the initial term). The initial term may refer to a bean or a message bundle map. It may also refer to a number of predefined objects called implicit objects.

here is the predefined objects in JSF 2.0
Variable Name | Meaning

header
A Map of HTTP header parameters, containing only the first
value for each name.

headerValues |
A Map of HTTP header parameters, yielding a String[] array of all values for a given name.

param |
A Map of HTTP request parameters, containing only the first
value for each name.

paramValues |
A Map of HTTP request parameters, yielding a String[] array of all values for a given name.

cookie |
A Map of the cookie names and values of the current request.

initParam |
A Map of the initialization parameters of this web application.

requestScope |
A Map of all request scope attributes.

viewScope |
A Map of all view scope attributes.

sessionScope |
A Map of all session scope attributes.

applicationScope |
A Map of all application scope attributes.

flash |
A Map for forwarding objects to the next view.

resource |
A Map of application resources.

facesContext |
The FacesContext instance of this request.

view |
The UIViewRoot instance of this request.

component |
The current component

cc |
The current composite component

你可能感兴趣的:(bean,Web,JSF,Flash,Access)