Java Reference
In-Depth Information
<map-entries>
<key-class>java.math.BigDecimal</key-class>
...
</map-entries>
This declaration will convert all the keys into
java.math.BigDecimal
. Of course,
you must make sure the keys can be converted to the type you specify. The key from the
example in this section cannot be converted to a
BigDecimal
, because it is a
String
.
If you want to specify a different type for all the values in the map, include the
value-
class
element after the
key-class
element:
<map-entries>
<key-class>int</key-class>
<value-class>java.math.BigDecimal</value-class>
...
</map-entries>
Note that this tag sets only the type of all the
value
subelements.
Each
map-entry
in the preceding example includes a
value
subelement. The
value
subelement defines a single value, which will be converted to the type specified in the
bean.
Instead of using a
map-entries
element, it is also possible to assign the entire map us-
ing a
value
element that specifies a map-typed expression.
Initializing Array and List Properties
The
list-entries
element is used to initialize the values of an array or
List
prop-
erty. Each individual value of the array or
List
is initialized using a
value
or
null-
value
element. Here is an example:
<managed-bean>
...
<managed-property>
<property-name>books</property-name>
<list-entries>
<value-class>java.lang.String</value-class>
<value>Web Servers for Fun and Profit</value>
<value>#{myBooks.bookId[3]}</value>