Java Reference
In-Depth Information
<null-value/>
</list-entries>
</managed-property>
</managed-bean>
This example initializes an array or a
List
. The type of the corresponding property in the
bean determines which data structure is created. The
list-entries
element defines
the list of values in the array or
List
. The
value
element specifies a single value in the
array or
List
and can reference a property in another bean. The
null-value
element
will cause the
setBooks
method to be called with an argument of
null
. A
null
prop-
erty cannot be specified for a property whose data type is a Java primitive, such as
int
or
boolean
.
Initializing Managed Bean Properties
Sometimes you might want to create a bean that also references other managed beans so
you can construct a graph or a tree of beans. For example, suppose you want to create a
bean representing a customer's information, including the mailing address and street ad-
dress, each of which is also a bean. The following
managed-bean
declarations create a
CustomerBean
instance that has two
AddressBean
properties: one representing the
mailing address, and the other representing the street address. This declaration results in
a tree of beans with
CustomerBean
as its root and the two
AddressBean
objects as
children.
<managed-bean>
<managed-bean-name>customer</managed-bean-name>
<managed-bean-class>
com.example.mybeans.CustomerBean
</managed-bean-class>
<managed-bean-scope> request </managed-bean-scope>
<managed-property>
<property-name>mailingAddress</property-name>
<value>#{addressBean}</value>
</managed-property>
<managed-property>
<property-name>streetAddress</property-name>
<value>#{addressBean}</value>
</managed-property>
<managed-property>
<property-name>customerType</property-name>
<value>New</value>
</managed-property>