Backing Bean Management
Another critical function of Web applications is proper management of resources. This includes separating the definition of UI component objects from objects that perform application-specific processing and hold data. It also includes storing and managing these object instances in the proper scope.
web应用中另一个关键的功能就是适当的管理资源。这包括将UI组件对象的定义和处理应用程序指定的功能和保存数据的对象分开。它还包括在适当的范围中保存和管理这些对象实例。
A typical JavaServer Faces application includes one or more backing beans, which are JavaBeans components (see JavaBeans Components) associated with UI components used in a page. A backing bean defines UI component properties, each of which is bound to either a component's value or a component instance. A backing bean can also define methods that perform functions associated with a component, including validation, event handling, and navigation processing.
一个典型的JSF应用包括一个或多个后台bean,在页面中,这是和UI组件有关联关系的JavaBeans组件。一个后台bean定义了UI组件的属性,每一个属性都绑定到组件的值或者实例。一个后台bean也可以定义和组件相关,并执行一定功能的方法,包括验证,事件处理,导航处理。
To bind UI component values and instances to backing bean properties or to reference backing bean methods from UI component tags, page authors use the JavaServer Faces expression language (EL) syntax. This syntax uses the delimiters #{}. A JavaServer Faces expression can be a value-binding expression (for binding UI components or their values to external data sources) or a method-binding expression (for referencing backing bean methods). It can also accept mixed literals and the evaluation syntax and operators of the JSP 2.0 expression language (see Expression Language).
如果要绑定UI组件的值和实例到后台bean的属性或者通过UI组件的标记引用后台bean的方法,那么页面开发者需要使用JSF表达式语言语法。这种语法使用“#{}”指示符。一个JSF的表达式可以是值绑定的(绑定UI组件或者他们的值到外部数据源)或者方法绑定(引用后台bean的方法)。它也可以使用JSP2.0中的语法。
To illustrate a value-binding expression and a method-binding expression, let's suppose that the userNo tag of the guessNumber application referenced a method that performed the validation of user input rather than using the LongRangeValidator:
为了演示值绑定表达式和方法绑定表达式,让我们假设guessNumber应用的userNo标记引用了一个方法来作验证,而不是使用LongRangeValidator。
<h:inputText id="userNo" value="#{UserNumberBean.userNumber}" validator="#{UserNumberBean.validate}" /> This tag binds the userNo component's value to the UserNumberBean.userNumber backing bean property. It also refers to the UserNumberBean.validate method, which performs validation of the component's local value, which is whatever the user enters into the field corresponding to this tag.
这个标记将userNo组件的值绑定到UserNumberBean.userNumber后台bean的属性,这个方法对组件的本地值进行了验证。
The property bound to the component's value must be of a type supported by the component. For example, the






