开发者

JasperReports - Conditional style per locale?

开发者 https://www.devze.com 2023-04-09 08:52 出处:网络
Is there a way to use a different styles, or redefine a style, based on a repor开发者_如何学Ct parameter locale? I need to modify font sizes for certain languages.I have implemented this in the past u

Is there a way to use a different styles, or redefine a style, based on a repor开发者_如何学Ct parameter locale? I need to modify font sizes for certain languages.


I have implemented this in the past using external style templates. There is a sample on jasperforge that illustrates how to do this.

Once you've moved your styles to external templates, you can create locale specific templates. The templating mechanism allows you to inherit from and override specific styles, so the locale specific versions don't get overly bloated. The example I linked above includes inheriting from and overriding base styles.

In your reports, you can then load the appropriate template at render time.

One easy way to do this is:

  • provide the path to the template that you want to use as a parameter to the report

  • include a template tag in the jrxml file that references the parameter:

    <template><![CDATA[$P{TEMPLATE_PATH}]]></template>

Then, in the code that renders the report, just set the TEMPLATE_PATH parameter appropriately for the report locale.

Again, the linked documentation mentions how to do this.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号