Hello,
Is there a way (using Java) to read resource bundles under the administration folder if I only know the path or id of the bundle? Please see the screenshot below, these are the resource bundles that I want to get the contents of.
Thanks!
Hello,
Is there a way (using Java) to read resource bundles under the administration folder if I only know the path or id of the bundle? Please see the screenshot below, these are the resource bundles that I want to get the contents of.
Thanks!
You should be able to use the following
org.hippoecm.hst.resourcebundle.ResourceBundleUtils#getBundle(String basename, Locale locale, boolean fallbackToJavaResourceBundle)
Hi Jasper,
Thank you for the response. I did try it, but for some reason it wasnāt working. On debugging it appears that it doesnāt have the request context and so it is unable to lookup the document. I am able to get to the document node by querying it this way:
getSession()
.getRootNode()
.getNode("content/documents/administration/configuration")
.getNode("url.configurations")
Here, āurl.configurationsā is the id of the resource bundle. Now, Iām trying to figure out how to get the content (and properties) from the node.
I figured out how to get the HippoDocument from the node. The only issue I have now is how to get the RequestContext from a J2EE Filter.
Assuming that (a) you have some reason to execute your servlet filter before the HstFilter is executed and (b) it is fine to read only āliveā content of the resource bundle, you can possibly try this:
final ResourceBundleRegistry resourceBundleRegistry =
HstServices.getComponentManager().getComponent(ResourceBundleRegistry.class.getName());
if (resourceBundleRegistry != null) {
if (locale == null) {
bundle = resourceBundleRegistry.getBundle(basename);
} else {
bundle = resourceBundleRegistry.getBundle(basename, locale);
}
}
where locale
is the local you want to use from the bundle and basename
is the resource bundle id.
Regards,
Woonsan
Oh wow, awesome. Let me try that
Fantastic! Works really well!