Java Reference
In-Depth Information
Initializing Properties Using the
managed-property
Element
A
managed-property
element must contain a
property-name
element, which
must match the name of the corresponding property in the bean. A
managed-prop-
erty
element must also contain one of a set of elements that defines the value of the
property. This value must be of the same type as that defined for the property in the cor-
responding bean. Which element you use to define the value depends on the type of the
property defined in the bean.
Table 7-1
lists all the elements that are used to initialize a
value.
TABLE 7-1. Subelements of
managed-property
Elements That Define Property
Values
an
int
property (a primitive type) using the
value
subelement. You also use the
value
subelement to initialize
String
and other reference types. The rest of this section de-
scribes how to use the
value
subelement and other subelements to initialize properties of
Java
Enum
types,
Map
,
array
, and
Collection
, as well as initialization parameters.
Referencing a Java
Enum
Type
In this case, the
value
element of the
managed-property
element must be a
String
that matches one of the
String
constants of the
Enum
. In other words, the
String
must be one of the valid values that can be returned if you were to call
valueOf(Class, String)
on
enum
, where
Class
is the
Enum
class and
String
is the contents of the
value
subelement. For example, suppose the managed bean prop-
erty is the following: