Usecase:
[toc on_off::hide=1]
I would like to control report locale picked by JasperReports Server using parameters of the report, not the user session locale.
Is this achievable at all?
Resolution:
At this moment, based on locale used by user in JasperReports Server, the report will be executed using different bundle file. Take a look in this screencast: http://somup.com/cq1hIdnJQl
If you want to run report with french locale, user should be logged in with french locale as REPORT_LOCALE parameter is defined during report execution and it cannot be overwritten. There is a way to do something similar, but the change has to be made on report level.
The idea is to overwrite default REPORT_LOCALE parameter of subreport. By default you cannot overwrite this parameter for main report because it takes its value from the system. So, steps are next:
- Create an empty report;
- Create parameter Language
- Create its subreport and define its parameter REPORT_LOCALE like below:
<subreport> <reportElement x="0" y="0" width="560" height="560" uuid="16df228b-dfbb-4725-81dd-41ebc45a50a7"/> <subreportParameter name="REPORT_LOCALE"> <subreportParameterExpression> <![CDATA[new java.util.Locale($P{Language})]]> </subreportParameterExpression> </subreportParameter> <connectionExpression> <![CDATA[$P{REPORT_CONNECTION}]]> </connectionExpression> <subreportExpression> <![CDATA["ChildReport.jasper"]]> </subreportExpression> </subreport>
- Add several resource bundle files.
- Upload everything to JRS
- Enjoy the ability to schedule the report in locale you want.
I prepared a screencast which demonstrates this behavior: http://somup.com/cq11o2nJGr Also, new project attached with all of resources.
Recommended Comments
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now