10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<br />

<br />

<br />

This example initializes an array or a List. <strong>The</strong> type of the corresponding property in the bean<br />

determines which data structure is created. <strong>The</strong> list-entries element defines the list of values<br />

in the array or List. <strong>The</strong> value element specifies a single value in the array or List and can<br />

reference a property in another bean. <strong>The</strong> null-value element will cause the setBooks method<br />

to be called with an argument of null.Anull property cannot be specified for a property whose<br />

data type is a <strong>Java</strong> primitive, such as int or boolean.<br />

Initializing Managed Bean Properties<br />

Sometimes you might want to create a bean that also references other managed beans so that<br />

you can construct a graph or a tree of beans. For example, suppose that you want to create a<br />

bean representing a customer’s information, including the mailing address and street address,<br />

each of which is also a bean. <strong>The</strong> following managed-bean declarations create a CustomerBean<br />

instance that has two AddressBean properties: one representing the mailing address, and the<br />

other representing the street address. This declaration results in a tree of beans with<br />

CustomerBean as its root and the two AddressBean objects as children.<br />

<br />

customer<br />

<br />

com.mycompany.mybeans.CustomerBean<br />

<br />

request <br />

<br />

mailingAddress<br />

#{addressBean}<br />

<br />

<br />

streetAddress<br />

#{addressBean}<br />

<br />

<br />

customerType<br />

New<br />

<br />

<br />

<br />

addressBean<br />

<br />

com.mycompany.mybeans.AddressBean<br />

<br />

none <br />

Configuring Beans<br />

Chapter 14 • Configuring <strong>Java</strong>Server Faces Applications 443

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!