Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Change locale via report-parameter
Change locale via report-parameter [message #640844] Tue, 23 November 2010 10:49 Go to next message
Dominik Missing name is currently offline Dominik Missing nameFriend
Messages: 7
Registered: November 2010
Junior Member
Hi,

I am new to BIRT.

I currently open reports, that I have designed with BIRT Report Designer, via WebViewer.display()
out of an RCP-Application
.
The localization is done via different ".properties-files" and is working fine, except there should be an
option to change the language of the reports easily and dynamically.
So I thought, it would be comfortable to create a report-parameter to give the user the option to
choose the language at this point.

Now to my questions:
Is it possible to set the language of a report after the user selected one in the parameter-window?
Where and how can I access the locale-variable out of the ReportDesigner and set the value to the user-selection.

Thanks,
Dominik

PS: I use BIRT 2.5.2.
Re: Change locale via report-parameter [message #640980 is a reply to message #640844] Tue, 23 November 2010 18:08 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

In the beforeFactory you can set it like:

reportContext.getDesignHandle().setStringProperty("locale",
params["ReportLocale"].value);

In the above example I have tied the setting to a parameter that will
have values like de_DE. Take a look at the attached example.

Jason

<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.22"
id="1">
<property name="createdBy">Eclipse BIRT Designer Version
2.6.1.v20100902 Build &lt;2.6.1.v20100915-1750></property>
<property name="units">in</property>
<method name="beforeFactory"><![CDATA[

reportContext.getDesignHandle().setStringProperty("locale",
params["ReportLocale"].value);]]></method>
<property name="iconFile">/templates/blank_report.gif</property>
<property name="bidiLayoutOrientation">ltr</property>
<property name="imageDPI">96</property>
<parameters>
<scalar-parameter name="ReportLocale" id="9">
<property name="valueType">static</property>
<property name="dataType">string</property>
<property name="distinct">true</property>
<list-property name="selectionList">
<structure>
<property name="value">de_DE</property>
</structure>
<structure>
<property name="value">fr_FR</property>
</structure>
<structure>
<property name="value">zh_TW</property>
</structure>
<structure>
<property name="value">en_US</property>
</structure>
</list-property>
<property name="paramType">simple</property>
<property name="controlType">list-box</property>
<property name="mustMatch">true</property>
<property name="fixedOrder">true</property>
<structure name="format">
<property name="category">Unformatted</property>
</structure>
</scalar-parameter>
</parameters>
<styles>
<style name="report" id="4">
<property name="fontFamily">sans-serif</property>
<property name="fontSize">10pt</property>
</style>
<style name="crosstab-cell" id="5">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
<style name="crosstab" id="6">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
</styles>
<page-setup>
<simple-master-page name="Simple MasterPage" id="2">
<page-footer>
<text id="3">
<property name="contentType">html</property>
<text-property
name="content"><![CDATA[<value-of>new Date()</value-of>]]></text-property>
</text>
</page-footer>
</simple-master-page>
</page-setup>
<body>
<label id="7">
<method name="onCreate"><![CDATA[this.text =
reportContext.getLocale();]]></method>
<text-property name="text">gg</text-property>
</label>
<data id="8">
<structure name="numberFormat">
<property name="category">Currency</property>
<property name="pattern">###0.00</property>
</structure>
<list-property name="boundDataColumns">
<structure>
<property name="name">Column Binding</property>
<expression name="expression"
type="javascript">"1000.00"</expression>
<property name="dataType">decimal</property>
</structure>
</list-property>
<property name="resultSetColumn">Column Binding</property>
</data>
</body>
</report>


On 11/23/2010 5:49 AM, Dominik wrote:
> Hi,
>
> I am new to BIRT.
> I currently open reports, that I have designed with BIRT Report
> Designer, via WebViewer.display() out of an RCP-Application.
> The localization is done via different ".properties-files" and is
> working fine, except there should be an
> option to change the language of the reports easily and dynamically.
> So I thought, it would be comfortable to create a report-parameter to
> give the user the option to choose the language at this point.
>
> Now to my questions: Is it possible to set the language of a report
> after the user selected one in the parameter-window?
> Where and how can I access the locale-variable out of the ReportDesigner
> and set the value to the user-selection.
>
> Thanks,
> Dominik
>
> PS: I use BIRT 2.5.2.
>
Re: Change locale via report-parameter [message #641112 is a reply to message #640844] Wed, 24 November 2010 10:06 Go to previous message
Dominik Missing name is currently offline Dominik Missing nameFriend
Messages: 7
Registered: November 2010
Junior Member
Thank you very much.
Its working perfect.
Previous Topic:how to make birt supprt i18n in osgi application
Next Topic:Y-axis format
Goto Forum:
  


Current Time: Tue Apr 23 17:25:36 GMT 2024

Powered by FUDForum. Page generated in 0.05580 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top