Class ResourceBundleContentProvider
java.lang.Object
com.webmethods.caf.faces.data.object.ResourceBundleContentProvider
- All Implemented Interfaces:
IContentProvider
Adapts a ResourceBundle
to an IContentProvider
.
Emulates behaviour of f:loadBundle tag, generating "???key???" for the value of a missing resources.
Used internally by BaseFacesPreferencesBean.getPortletResources()
and BaseApplicationBean.getApplicationResources()
.
ResourceBundle rb = new ListResourceBundle { protected Object[][] getContents() { return new Object[][]{ {"company.name", "webMethods"}, } }; IContentProvider provider = new ResourceBundleContentProvider(rb); String contactName = provider.getValue("company.name"); // returns "webMethods"
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.Initializes provider with the given resource bundle. -
Method Summary
Modifier and TypeMethodDescriptionObject[]
Returns keys in the resource bundleReturns wrapped resource bundleClass<?>
Returns java type of the given propertyReturns the value from the resource bundle for the given keyReturns the value from the resource bundle for the given keyboolean
hasProperty
(Object propertyKey) Always returntrue
.void
setResourceBundle
(ResourceBundle bundle) Sets resource bundle to wrapMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.webmethods.caf.faces.data.IContentProvider
toString
-
Field Details
-
m_bundle
-
-
Constructor Details
-
ResourceBundleContentProvider
public ResourceBundleContentProvider()Default constructor.setResourceBundle(ResourceBundle)
must be called before use. -
ResourceBundleContentProvider
Initializes provider with the given resource bundle.- Parameters:
bundle
- resource bundle
-
-
Method Details
-
getValue
Returns the value from the resource bundle for the given key- Specified by:
getValue
in interfaceIContentProvider
- Parameters:
propertyKey
- the key to lookup the value in the resource bundle- Returns:
- the value from the resource bundle
- Throws:
PropertyNotFoundException
- if property is not supportedELException
-
getValue
public Object getValue(Object propertyKey, Object[] args) throws ELException, PropertyNotFoundException Returns the value from the resource bundle for the given key- Parameters:
propertyKey
- the key to lookup the value in the resource bundleargs
- the object array contains string substitution values- Returns:
- the formatted string from the resource bundle
- Throws:
ELException
PropertyNotFoundException
-
getType
Description copied from interface:IContentProvider
Returns java type of the given property- Specified by:
getType
in interfaceIContentProvider
- Parameters:
propertyKey
- the property key of typeString
orInteger
- Returns:
- property java
Class
- Throws:
PropertyNotFoundException
- if property is not supported
-
getPropertyKeys
Returns keys in the resource bundle- Specified by:
getPropertyKeys
in interfaceIContentProvider
- Returns:
- array of keys in the resource bundle
-
hasProperty
Always returntrue
.- Specified by:
hasProperty
in interfaceIContentProvider
- Parameters:
propertyKey
- property key of typeString
orInteger
- Returns:
true
if property is supported
-
getResourceBundle
Returns wrapped resource bundle- Returns:
- null if not set
-
setResourceBundle
Sets resource bundle to wrap- Parameters:
bundle
- resource bundle, must not be null
-