Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Show alternate display for code values
spacefrog
Hi all,
i try to display an alternate text for a given value in a report item. The report item is a code stored in the db.
We are using Hashtables serverside to translate each code to a display value (language driven). How could this be done by using the java birt api server side?
I have added a map rule for each value in my codeset hashmap:
**********
Map codes = (Map) codeTables.get(codeSetName);
if (codes != null) {
Iterator codeIt = codes.entrySet().iterator();
while (codeIt.hasNext()) {
Map.Entry<String, String> entry = (Map.Entry) codeIt.next();
MapRule mr = StructureFactory.createMapRule();
mr.setTestExpression("row["" + codeSetName + ""]");
mr.setOperator(DesignChoiceConstants.MAP_OPERATOR_EQ);
mr.setValue1(""" + entry.getKey() + """);
mr.setDisplay(entry.getValue());
PropertyHandle ph = ((ReportItemHandle) handle).getPropertyHandle(StyleHandle.MAP_RULES_PROP);
ph.addItem(mr);
}
}
**********
But i want to do it rather generic and not add a map rule for every code!
Is there a way to "extend" a map rule or even another construct for doing this? As i have a hashmap, this would be a simple hashmap lookup for every dataitem.
Regards,
/Stephan
Find more posts tagged with
Comments
mwilliams
Hi Stephan,
You might be able to create a computed column in your dataSet to create a new column that is the translated version of your coded field. Then, you could just use this new field in your report.
Hope this helps.
spacefrog
Hi Michael,
i have all the code value pairs in a hashmap and would like to do this through the API at serverside. Would that be possible?
Regards,
/Stephan
mwilliams
Stephan,
A computed column would utilize the API's on the server side.
spacefrog
How can i add a computed column where java code (server side) gets executed? Do you have an example?