Appears in:
<component-specification>
and <page-specification>
A <bean>
is used to add behaviors to a page or component via aggregation.
Each <bean>
defines a named JavaBean that is instantiated on demand.
Beans are accessed through the OGNL expression beans.
.
name
Once a bean is instantiated and initialized, it will be retained by the page or component for some period of time, specified by the bean's lifecycle.
bean lifecycle
The bean is not retained, a new bean will be created on each access.
The bean is retained for the lifecycle of the page itself.
The bean is retained until the current render operation completes. This will discard the bean when a page or form finishes rewinding.
The bean is retained until the end of the current request.
Caution should be taken when using lifeycle page
. A bean is associated
with a particular instance of a page within a particular JVM. Consecutive requests
may be processed using different instances of the page, possibly in different JVMs (if the application
is operating in a clustered environment). No state particular to a single client session should
be stored in a page.
Beans must be public classes with a default (no arguments) constructor. Properties of the bean
may be configured using the <set-property>
and <set-string-property>
elements.
Figure B.3. <bean>
Attributes
Name | Type | Required ? | Default Value | Description |
---|---|---|---|---|
name | string | yes | The name of the bean, which must be a valid Java identifier. | |
class | string | yes | The name of the class to instantiate. | |
lifecycle | none|page|render|request | no | request | As described above; duration that bean is retained. |
Figure B.4. <bean>
Elements
<description>
*, <property>
*,
(<set-property>
| <set-string-property>
) *