|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.cocoon.faces.samples.carstore.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 String |
CONVERTER_ERROR_MESSAGE_ID
The message identifier of the Message to be created if the conversion fails. |
protected static org.apache.commons.logging.Log |
log
|
Constructor Summary | |
---|---|
CarBean()
|
|
CarBean(String bundleName)
|
Method Summary | |
---|---|
Map |
getAttributes()
|
Map |
getComponents()
|
Integer |
getCurrentPrice()
|
ArrayList |
parseStringIntoArrayList(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
String value,
String valueType,
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. |
String |
updatePricing()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final org.apache.commons.logging.Log log
public static final 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(String bundleName)
Method Detail |
---|
public ArrayList parseStringIntoArrayList(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, String value, String valueType, javax.faces.convert.Converter converter)
public String updatePricing()
public Integer getCurrentPrice()
public Map getComponents()
public Map getAttributes()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |