Home
Analytics
dynamic theme for the libraries
XFabien
Hello Birts' Experts,
I have a question about changing the theme for the libraries not for the report.
I created a library 'Themes.rptlibrary' who has 2 themes (theme1 and theme2). And I created another library 'Items.rptlibrary' who contains all the report items (table, crosstab...) and it used the theme from the library 'Themes.rptlibrary'. By the default, I used the theme1.
Now my problem is to change the theme1 to theme2 for the output format pdf.
I know how to change it in the report, but it can not work for the library.
So, does anybody know how to do it?
I appreciate very much your help.
Find more posts tagged with
Comments
mwilliams
What do you mean by "I know how to change it in the report, but it can not work for the library"? It's not working for elements that come from the library? Is that what you mean? Let me know. Also, let me know your BIRT version.
XFabien
Hello Michael,
Sorry for not explaining well. What I mean is that I can change the theme in the beforeFactory event.
But it can not work for the report item that come from the library.
My birt version is 2.6.2
Thanks for the help.
Yao
mwilliams
This beforeFactory code should work:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
importPackage (Packages.org.eclipse.birt.report.model.api);
lh = reportContext.getDesignHandle().findLibrary("myLibrary.rptlibrary");
theme1 = lh.getThemes().get(0);
theme2 = lh.getThemes().get(1);
if (reportContext.getOutputFormat() == "pdf"){
lh.setTheme(theme2);
}
else{
lh.setTheme(theme1);
}
</pre>
<br />
Let me know.
XFabien
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="101295" data-time="1337879928" data-date="24 May 2012 - 10:18 AM"><p>
This beforeFactory code should work:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
importPackage (Packages.org.eclipse.birt.report.model.api);
lh = reportContext.getDesignHandle().findLibrary("myLibrary.rptlibrary");
theme1 = lh.getThemes().get(0);
theme2 = lh.getThemes().get(1);
if (reportContext.getOutputFormat() == "pdf"){
lh.setTheme(theme2);
}
else{
lh.setTheme(theme1);
}
</pre>
<br />
Let me know.<br /></p></blockquote>
<br />
<br />
Thanks Michael.<br />
<br />
Unluckyly, it doesn't work. I'll add the report test here so that you can figure it out.<br />
<br />
mwilliams
My guess is you're running into an issue because you're not giving the actual library path. You have it in a file called "Lib", so you need to do "Lib/lib.rptlibrary". Try that and let me know. Your design was corrupt, so I couldn't try it.
XFabien
You are right.
But if the themes are saved in one library theme.rptlibray, and only the report items in the library lib.rptlibray that use the theme.
The script doesn't work correctly.
mwilliams
Ok, now I see that your library has a library.
Try this:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
importPackage (Packages.org.eclipse.birt.report.model.api);
lh = reportContext.getDesignHandle().findLibrary("Lib/lib.rptlibrary");
lh2 = reportContext.getDesignHandle().findLibrary("Lib/lib.rptlibrary").findLibrary("Lib/theme.rptlibrary");
theme1 = lh2.getThemes().get(0);
theme2 = lh2.getThemes().get(1);
if (reportContext.getOutputFormat() == "pdf"){
lh.setTheme(theme2);
}
else{
lh.setTheme(theme1);
}
</pre>
appform
Hi All,
I want to place a datasource,dataset and a parameter in library and want to use this library in other reports.
I don't know anything about library means how to create a library and how to add to other reports.
Please give me a example file for the same purpose.I am using Eclipse BIRT Designer Version 2.6.3.
Thanks
mwilliams
All you need to do is do it just like creating a report design. Go to new, only choose library. Now, you create dataSources, dataSets and elements, just like you would with your report. To use the library, open up your report and go to the outline view. Here, you'll right click on the library section and choose to use a library. You'll pick your library from the directory and accept. Now, you add the elements to your report, from your library. To do this, you open the resource explorer view and find your library. When you expand your library, you'll find the dataSources, dataSets, etc. that you created. You can right click on them, in the explorer and choose to use them in your report or you can drag them from the resource explorer down to the outline and drop them in the appropriate section of your report.
Hope this helps. Let me know.