Ifamanaged-beanelementdoesnotcontainothermanaged-beanelements,itcancontainonemap-entrieselementorlist-entrieselement.Themap-entrieselementconfiguresasetofbeansthatareinst...
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 element configures a set of beans that are instances of List.
To map to a property defined by a managed-property element, you must ensure that the part of a component tag’s value expression after the period matches the managed-property element’s property-name element. In the earlier example, the shape property is initialized with the value poly. The next section explains in more detail how to use the managed-property element.
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-property element must also contain one of a set of elements (listed in Table 14-1) that defines the value of the property. This value must be of the same type as that defined for the property in the corresponding bean. Which element you use to define the value depends on the type of the property defined in the bean. Table 14-1 lists all the elements used to initialize a value.
Table 14-1 Subelements of managed-property Elements That Define Property Values
Element
Value That It Defines
list-entries
Defines the values in a list
map-entries
Defines the values of a map
null-value
Explicitly sets the property to null
value
Defines a single value, such as a String or int, or a JavaServer Faces EL expression
Using the managed-bean Element includes an example of initializing String properties using the value subelement. You also use the value subelement to initialize primitive and other reference types. The rest of this section describes how to use the value subelement and other subelements to initialize properties of Java Enum types, java.util.Map, array, and Collection, as well as initialization parameters.
展开