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)
locale bound to a parameter
cyboitel
Hello,
I'm a new user of BIRT and I want to know if there is a way to bind the locale of my report to a parameter.
I explain :
I have a parameter which is lgCode set to english or french to load my data in different table.
I want to set the locale of my report conditionally to the corresponding language.
I know that I can change the URL locale parameter of my viewer, but I want to change it dynamically and linked to my parameter.
Thanks,
Cyrille
Find more posts tagged with
Comments
mwilliams
Hi Cyrille,<br />
<br />
This post from the devShare talks about using a report parameter to dynamically set the locale.<br />
<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/devshare/designing-birt-reports/1119-localizing-birt-reports-with-report-parameters/#description'>Localizing
BIRT Reports with report parameters - Designs & Code - BIRT Exchange</a><br />
<br />
Hope this helps.
cyboitel
Thank you for your quick answer.
Nevertheless, I'm looking for a way to set the locale property at the report level to, for example, change my date format dynamically based on a report parameter.
Thank you in advance
JasonW
You can set the locale of the report using the URL parmaeter __locale=fr_FR as stated in the link Michael posted. This is generally the best approach. If you want to try it in script put something like this in the beforeFactory:
importPackage(Packages.java.util);
importPackage(Packages.org.eclipse.birt.report.engine.api.impl);
importPackage(Packages.org.eclipse.birt.report.context);
importPackage(Packages.org.eclipse.birt.report.utility);
var req = reportContext.getHttpServletRequest();
var attrbean = req.getAttribute("attributeBean");
var cTaskId = attrbean.getTaskId();
var taskMap = req.getSession().getAttribute("tasks");
var rTask = taskMap.get(cTaskId).getTask();
var lc = new Locale("de_AT");
rTask.setLocale(lc);
replace the locale string with your report parameter value.
Jason
cyboitel
Thank you,
it works very well.
Cyrille
cyboitel
I have spoken to fast.
The script works on the preview but doesn't work in PDF generation.
The script bugs on the line :
"var rTask = taskMap.get(cTaskId).getTask();"
I have the following error :
"org.mozilla.javascript.EcmaError: TypeError: Cannot call method "getAttribute" of null"
Thanks for help
JasonW
How are you running the pdf? In the viewer or the report engine api? If you are using the viewer are you exporting to pdf or directly to pdf?
Jason
cyboitel
Hello,
I'm using BIRT viewer but I'm going to use the API nextly.
I'm exporting to PDF.
Cyrille