|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcarstore.CarBean
public class CarBean
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
.
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.
Field Summary | |
---|---|
static java.lang.String |
CONVERTER_ERROR_MESSAGE_ID
The message identifier of the Message to be created if the conversion fails. |
Constructor Summary | |
---|---|
CarBean()
|
|
CarBean(java.lang.String bundleName)
|
Method Summary | |
---|---|
java.util.Map<java.lang.String,java.lang.Object> |
getAttributes()
|
java.util.Map |
getComponents()
|
java.lang.Integer |
getCurrentPrice()
|
java.util.List<javax.faces.model.SelectItem> |
parseStringIntoArrayList(java.lang.String value,
javax.faces.convert.Converter converter)
Tokenizes the passed in String which is a comma separated string of option values that serve as keys into the main resources file. |
java.lang.String |
updatePricing()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String CONVERTER_ERROR_MESSAGE_ID
The message identifier of the Message to be created if
the conversion fails. The message format string for this
message may optionally include a {0}
placeholder, which will be replaced by the object and value.
Constructor Detail |
---|
public CarBean()
public CarBean(java.lang.String bundleName)
Method Detail |
---|
public java.util.List<javax.faces.model.SelectItem> parseStringIntoArrayList(java.lang.String value, javax.faces.convert.Converter converter)
Tokenizes the passed in String which is a comma separated string of option values that serve as keys into the main resources file. For example, optionStr could be "Disc,Drum", which corresponds to brake options available for the chosen car. This String is tokenized and used as key into the main resource file to get the localized option values and stored in the passed in ArrayList.
value
- a comma separated String of valuesconverter
- currently ignored
List
of SelectItem
instances
parsed from value
public java.lang.String updatePricing()
public java.lang.Integer getCurrentPrice()
public java.util.Map getComponents()
public java.util.Map<java.lang.String,java.lang.Object> getAttributes()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |