Java Reference
In-Depth Information
a.
Type the display name of the bean in the Bean Name field.
b.
Click Browse to locate the bean's class.
9.
In the Browse Class dialog box:
a.
Start typing the name of the class you are looking for in the Class Name field.
While you are typing, the dialog will show the matching classes.
b.
Select the class from the Matching Classes box.
c.
Click OK.
10.
In the Add Managed Bean dialog box:
a.
Select the bean's scope from the Scope menu.
b.
Click Add.
The preceding steps will add the
managed-bean
element and three elements inside of
that element: a
managed-bean-name
element, a
managed-bean-class
element,
and a
managed-bean-scope
element. You will need to edit the XML of the configur-
ation file directly to further configure this managed bean.
The
managed-bean-name
element defines the key under which the bean will be stored
in a scope. For a component's value to map to this bean, the component tag's
value
at-
tribute must match the
managed-bean-name
up to the first period.
The
managed-bean-class
element defines the fully qualified name of the JavaBeans
component class used to instantiate the bean.
The
managed-bean
element can contain zero or more
managed-property
ele-
ments, each corresponding to a property defined in the bean class. These elements are
used to initialize the values of the bean properties. If you don't want a particular property
initialized with a value when the bean is instantiated, do not include a
managed-prop-
erty
definition for it in your application configuration resource file.
If a
managed-bean
element does not contain other
managed-bean
elements, it can
contain one
map-entries
element or
list-entries
element. The
map-entries
element configures a set of beans that are instances of
Map
. The
list-entries
ele-
ment configures a set of beans that are instances of
List
.
In the following example, the
newsletters
managed bean, representing a
UISelectItems
component, is configured as an
ArrayList
that represents a set of
SelectItem
objects. Each
SelectItem
object is in turn configured as a managed
bean with properties: