This bean encapsulates a car model, including pricing and package
choices. The system allows the user to customize the properties of
this bean with the help of the
CarCustomizer .
Data Access
This is the only bean in the system that has complicated access to
the persistent store of data. In the present implementation, this
persistent store is in ResourceBundle instances.
There are three data source ResourceBundle files
used:
<ModelName>
This contains the localized content for this model. There
is a variant of this file for each supported locale, for
example, Jalopy_de.properties
<Common_properties>
This contains the localized content common to all
models.
<ModelName_options>
This contains the non-localized content for this model,
including the non-localized options. There is only one
variant of this file for all locales for example,
Jalopy_options.properties
All files conform to the following convention:
key
key_componentType
key_valueType
Where key is the name of an attribute of this car.
For example, basePrice , or description .
key_componentType is the component type of the
UIComponent subclass to be used to represent this
attribute in the page, for example SelectManyMenu .
key_valueType is the data type of the value of the
UIComponent , for example java.lang.Integer .
For all non-String valueTypes.
When the bean is instantiated, we load both of the above
properties files and iterate over the keys in each one. For each
key, we look at the componentType and ask the
Application to create a component of that type. We
store that UIComponent instance in our
components Map under the name
key . We look at the valueType for the
key . For non java.lang.String types, we
ask the Application for a Converter
instance for that class. If found, we use it to convert the value
for the key to the appropriate type and store that as
the value of the UIComponent instance.
|