Java Reference
In-Depth Information
Click here to view code image
<managed-bean>
<managed-bean-name>newsletters</managed-bean-name>
<managed-bean-class>java.util.ArrayList</managed-bean-class>
<managed-bean-scope>application</managed-bean-scope>
<list-entries>
<value-class>javax.faces.model.SelectItem</value-class>
<value>#{newsletter0}</value>
<value>#{newsletter1}</value>
<value>#{newsletter2}</value>
<value>#{newsletter3}</value>
</list-entries>
</managed-bean>
<managed-bean>
<managed-bean-name>newsletter0</managed-bean-name>
<managed-bean-class>javax.faces.model.SelectItem</managed-bean-
class>
<managed-bean-scope>none</managed-bean-scope>
<managed-property>
<property-name>label</property-name>
<value>Duke's Quarterly</value>
</managed-property>
<managed-property>
<property-name>value</property-name>
<value>200</value>
</managed-property>
</managed-bean>
...
This approach may be useful for quick-and-dirty creation of selection item lists, before a
development team has had time to create such lists from the database. Note that each of
the individual newsletter beans has a managed-bean-scope setting of none , so that
they will not themselves be placed into any scope.
See “ Initializing Array and List Properties on page 153 for more information on config-
uring collections as beans.
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 maximum
property is initialized with the value 10 . The following section,“ Initializing Properties
Using the managed-property Element on page 150 , explains in more detail how to
use the managed-property element. See “ Initializing Managed Bean Properties ” on
page 153 for an example of initializing a managed bean property.
Search WWH ::




Custom Search