|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.ibm.commerce.common.beans.ResourceBundleDataBean
The ResourceBundleDataBean is used by JSPs to get information from property files. To find a property file, three parameters are needed:
store1/UserRegistration_en_US.properties store1/UserRegistration_fr_Fr.properties store2/UserRegistration_en_US.properties store2/UserRegistration_fr_Fr.propertiesTo find the property files belong to store1, you need call setDirectoryName("store1") before you active the ResourceBundleDataBean.
After you set these parameters, you can get information of a property file using two methods:
Field Summary | |
static java.lang.String |
CLASSNAME
|
static java.lang.String |
ORDERNAME
|
Constructor Summary | |
ResourceBundleDataBean()
ResourceBundleDataBean constructor. |
Method Summary | |
CommandContext |
getCommandContext()
|
java.lang.String |
getDelimiter()
Gets the delimiter for the property file. |
java.util.Locale |
getLocale()
Gets the Locale. |
java.lang.String |
getPathSeparator()
Gets the path separator. |
java.lang.String |
getPropertyFileName()
Gets the name of property file |
java.util.Hashtable |
getPropertyHashtable()
Return a the content of the property file as one large Hashtable. |
java.util.Hashtable |
getPropertyHashtable(java.util.SortedMap atmpProperty)
Insert the method's description here. |
java.util.PropertyResourceBundle |
getPropertyResourceBundle()
Return a PropertyResourceBundle object. |
java.util.SortedMap |
getPropertySortedMap()
Return a the content of the property file as one large Hashtable. |
TypedProperty |
getRequestProperties()
|
java.lang.String |
getSeparator()
Gets the separator for the property file. |
java.lang.String |
getStoreDirectory()
Gets the name of the store directory, which is used for finding property files belong to this store. |
boolean |
getStoreDirectoryEnabled()
Gets a boolean which indicates if enable getting the Store Directory from the CommandContext. |
static java.lang.String |
invokeGetMethod(java.lang.String astrClassName,
java.lang.Object aobjAccessBean,
java.lang.String astrParameterName)
Insert the method's description here. |
void |
populate()
|
void |
setCommandContext(CommandContext acommandContext)
|
void |
setDelimiter(java.lang.String astrDelimiter)
Sets the delimiter for the property file. |
void |
setLocale(java.util.Locale alcLocale)
Set the Locale. |
void |
setPathSeparator(java.lang.String astrPathSeparator)
Sets the path separator. |
void |
setPropertyFileName(java.lang.String astrPropertyFileName)
Sets the name of property file. |
void |
setRequestProperties(TypedProperty areqParms)
|
void |
setSeparator(java.lang.String astrSeparator)
Sets the separator for the property file. |
void |
setStoreDirectory(java.lang.String astrStoreDirectory)
Sets the name of store directory, which is used as the path to the find the property file. |
void |
setStoreDirectoryEnabled(boolean abStoreDirectoryEnabled)
Sets if enable getting the Store Directory from the CommandContext. |
static java.lang.String |
toUpOneChar(java.lang.String strAttributeName)
Input parameter: attribute name return: method name (with uppercase first character) uppercase the first character of the attribute name in order to match with the naming convention of the underlying get/set method |
Field Detail |
public static final java.lang.String CLASSNAME
public static final java.lang.String ORDERNAME
Constructor Detail |
public ResourceBundleDataBean()
Method Detail |
public CommandContext getCommandContext()
public java.lang.String getDelimiter()
age.Options=0;Not Available|1;10-19 years|2;20-29 years"|" is the delimitor.
public java.util.Locale getLocale()
public java.lang.String getPathSeparator()
"store1/UserRegistration""/" is the path separator.
public java.lang.String getPropertyFileName()
public java.util.Hashtable getPropertyHashtable()
Return a the content of the property file as one large Hashtable. This Hashtable contains many field Hastables (each field corresponding to one small hashtable).
For example:
If you have a property file named UserRegistration_en_US.properties, which contains the following content:
. . . children.Label=Number Of Children children.Displayed=yes children.Required=no age.Label=Age age.Displayed=yes age.Required=no age.Options=0;Not Available|1;10-19 years|2;20-29 years|3;30-39 years|4;40-49 years|5;50-59 years|6;60 years or older age.Operators=>Older than|<;Yonger than|!=;Not equal to gender.Label=Gender gender.Displayed=yes gender.Required=no gender.Options=Male|Female text1 = User Registration. . .
Note:
| -- Default Delimiter (You can use setDelimiter(String) method to set a different Delimiter)
; -- Default Separator (You can use setSeparator(String) method to set a different Separator)
To read this file, following the following steps:
ResourceBundleDataBean bnResourceBundle= new ResourceBundleDataBean(); bnResourceBundle.setPropertyFileName("UserRegistration"); com.ibm.commerce.beans.DataBeanManager.activate(bnResourceBundle, request); Hashtable hshRegister = bnResourceBundle.getPropertyHashtable();
Hashtable hshChildren = (Hashtable) hshRegister.get("children"); Hashtable hshAge = (Hashtable) hshRegister.get("age"); Hashtable hshGender = (Hashtable) hshRegister.get("gender");for the entry which only have attribute name, you can use the following code to get the value:
String strTitle = (String) hshRegister.get("text1");
String strChildrenLabel = (String)hshChildren.get("Label")
if (((Boolean)hshChildren.get("Displayed").booleanValue()) { ... }
String[ ][ ] ageOptions = (String[ ][ ])hshAge.get("Options"); ageOptions[0][0] should be "0" ageOptions[0][1] should be "Not Available" ageOptions[1][0] should be "1" ageOptions[1][1] should be "10-19 years" If there is no separator, the internal value and display value will be same, for example String[ ][ ] genderOptions = (String[ ][ ])hshGender.get("Options"); genderOptions[0][0] should be "Male" genderOptions[0][1] should be "Male" genderOptions[1][0] should be "Famal" genderOptions[1][1] should be "Female"
public java.util.Hashtable getPropertyHashtable(java.util.SortedMap atmpProperty)
atmpProperty
- java.util.SortedMappublic java.util.PropertyResourceBundle getPropertyResourceBundle()
public java.util.SortedMap getPropertySortedMap()
Return a the content of the property file as one large Hashtable. This Hashtable contains many field Hastables (each field corresponding to one small hashtable).
For example:
If you have a property file named UserRegistration_en_US.properties, which contains the following content:
. . . children.Label=Number Of Children children.Displayed=yes children.Required=no age.Label=Age age.Displayed=yes age.Required=no age.Options=0;Not Available|1;10-19 years|2;20-29 years|3;30-39 years|4;40-49 years|5;50-59 years|6;60 years or older age.Operators=>Older than|<;Yonger than|!=;Not equal to gender.Label=Gender gender.Displayed=yes gender.Required=no gender.Options=Male|Female text1 = User Registration. . .
Note:
| -- Default Delimiter (You can use setDelimiter(String) method to set a different Delimiter)
; -- Default Separator (You can use setSeparator(String) method to set a different Separator)
To read this file, following the following steps:
ResourceBundleDataBean bnResourceBundle= new ResourceBundleDataBean(); bnResourceBundle.setPropertyFileName("UserRegistration"); com.ibm.commerce.beans.DataBeanManager.activate(bnResourceBundle, request); Hashtable hshRegister = bnResourceBundle.getPropertyHashtable();
Hashtable hshChildren = (Hashtable) hshRegister.get("children"); Hashtable hshAge = (Hashtable) hshRegister.get("age"); Hashtable hshGender = (Hashtable) hshRegister.get("gender");for the entry which only have attribute name, you can use the following code to get the value:
String strTitle = (String) hshRegister.get("text1");
String strChildrenLabel = (String)hshChildren.get("Label")
if (((Boolean)hshChildren.get("Displayed").booleanValue()) { ... }
String[ ][ ] ageOptions = (String[ ][ ])hshAge.get("Options"); ageOptions[0][0] should be "0" ageOptions[0][1] should be "Not Available" ageOptions[1][0] should be "1" ageOptions[1][1] should be "10-19 years" If there is no separator, the internal value and display value will be same, for example String[ ][ ] genderOptions = (String[ ][ ])hshGender.get("Options"); genderOptions[0][0] should be "Male" genderOptions[0][1] should be "Male" genderOptions[1][0] should be "Famal" genderOptions[1][1] should be "Female"
public TypedProperty getRequestProperties()
public java.lang.String getSeparator()
age.Options=0;Not Available|1;10-19 years|2;20-29 years"1;10-19 years" is a option, ";" is the separator. If no separator is set, the databean will use the default one: ";".
public java.lang.String getStoreDirectory()
public boolean getStoreDirectoryEnabled()
public static java.lang.String invokeGetMethod(java.lang.String astrClassName, java.lang.Object aobjAccessBean, java.lang.String astrParameterName)
astrClassName
- java.lang.StringastrParameterName
- java.lang.Stringpublic void populate()
public void setCommandContext(CommandContext acommandContext)
public void setDelimiter(java.lang.String astrDelimiter)
age.Options=0;Not Available|1;10-19 years|2;20-29 years"|" is the delimitor. If no Delimiter is set, the databean will use the default one: "|".
astrDelimiter
- The delimiter for the property filepublic void setLocale(java.util.Locale alcLocale)
alcLocale
- The Localepublic void setPathSeparator(java.lang.String astrPathSeparator)
"store1/UserRegistration""/" is the path separator.
astrPathSeparator
- The path separatorpublic void setPropertyFileName(java.lang.String astrPropertyFileName)
astrPropertyFileName
- The name of property filepublic void setRequestProperties(TypedProperty areqParms) throws java.lang.Exception
public void setSeparator(java.lang.String astrSeparator)
age.Options=0;Not Available|1;10-19 years|2;20-29 years"1;10-19 years" is a option, ";" is the separator. If no separator is set, the databean will use the default one: ";".
astrSeparator
- The separator for the property filepublic void setStoreDirectory(java.lang.String astrStoreDirectory)
astrStoreDirectory
- The name of store directorypublic void setStoreDirectoryEnabled(boolean abStoreDirectoryEnabled)
abStoreDirectoryEnabled
- A boolean value indicating if getting the Store
Directory from the CommandContextpublic static java.lang.String toUpOneChar(java.lang.String strAttributeName)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |