How do I load a resource bundle properties file in a composite component?
My component library's directory tree is configured like this:
resources
mylib
css
mycomponent.css
properties
mycomponent.properties
mycomponent.xhtml
I would like to load a properties file in mycomponent.xhtml to use for posts. What is the correct way to do this? Is there a solution like f: loadbundle?
+3
source to share
1 answer
Composites have hidden support for resource bundles via #{cc.resourceBundleMap}
. It only requires:
- The Bundle file is placed in the same (sub) folder as the XHTML compound.
- The Bundle file has exactly the same filename (prefix) as the XHTML compound.
So, if you change the structure a little,
WebContent |-- resources | `-- mylib | |-- mycomponent.css | |-- mycomponent.properties | `-- mycomponent.xhtml :
Then you should be able to access it like below:
<cc:implementation>
<h:outputStylesheet library="mylib" name="mycomponent.css" />
...
<p>Property with key "foo": #{cc.resourceBundleMap.foo}</p>
<p>Property with key "foo.bar": #{cc.resourceBundleMap['foo.bar']}</p>
</cc:implementation>
+4
source to share