六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 484|回复: 0

JSF 2.0 learning notes

[复制链接]

升级  10%

1

主题

1

主题

1

主题

童生

Rank: 1

积分
5
 楼主| 发表于 2013-1-29 22:41:46 | 显示全部楼层 |阅读模式
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
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表