[opencms-dev] Debug XML bundle access in formatter JSP
Thorsten Duhn
duhn at regio-gmbh.de
Tue Mar 4 10:32:40 CET 2014
Hello,
I might need some assistance again. I need to access XML bundle content
in JSP Java code. Underlying problem is that I need to handle categories
for some Solr filtering and need it multiligunal (and also sorted) in an
pulldown menu. As I found no way to solve this in taglib I coded it
along Java API. As there is (AFAIK) no prefered way to manage category
titles for different languages (storing categories separated for each
language makes managing our content a lot more difficult) I decided to
introduce an XML bundle within my category tree to store the
translations. But unfortunately it works in one formatter, but not in
another with quite identical setup. Access to the bundle always falls
back to default (German), does not find translation for key. Now I don't
know how I may debug this to see what the problem is, why key is not
found in bundle while I'm quite sure I loaded the correct bundle and key
is available for requested locale.
This is the Java code in Question:
if (! categoryList.isEmpty()) {
List<String> optionList = new ArrayList<String>();
CmsXmlMessages messages = null;
if (cmsObject.existsResource(
repositoryPath
+ categoryName
+ "/messages.xml") ) {
messages = new org.opencms.xml.CmsXmlMessages(
"messages.xml",
repositoryPath + categoryName + "/messages.xml",
null,
currentLocale);
}
for (CmsCategory cat : categoryList) {
String catTitle = cat.getTitle();
if (messages != null) {
catTitle = messages.keyDefault(cat.getName(), catTitle);
}
/* ... */
}
/* ... */
}
Category hierarchy is quite plain, I have one base category
(categoryName) and the categories in question in it, no deeper
structure. List of categories (categoryList) is correctly filled, as the
resulting pulldown has the correct values, just not translated but with
it's original title (at the end of the code above keyDefault always
returns default).
As I said, exact the same code works in another formatter. I just don't
know how to debug such. F.i. CmsXmlMessages object has no methods to
list available keys, isInitialized returns false in both cases, in
working and in this formatter.
I was not able to get my OpenCms instance connected to my Eclipse IDE,
so everything I do is inside Workplace.
Regards,
Thorsten
More information about the opencms-dev
mailing list