BIRT Exchange Forum: BIRT Exchange Forum -> Michael's BIRT Blog

Jump to content


 

BIRT Poll: To best make a table fill a pdf page before breaking (PL=page layout, PBI=page break interval) set:

PL: auto, PBI: 0PL: fixed, PBI: 0PL: auto, PBI: 1000000PL: fixed, PBI: 1000000
Page 1 of 1

Drop Elements Depending on Output Format

Posted by mwilliams  Icon, 08 March 2013 - 06:34 PM

Sometimes when designing a report, you want to only show certain elements in certain output formats. Not just hide them, but actually drop them, so the bound dataSet doesn't run or for saved processing time. Say you want to drop a certain element from your report when you run your report to the XLS output. To do this, you'd simply name your report element in the property editor, then put the following in your beforeFactory script:

if(reportContext.getOutputFormat() == "xls"){

	reportContext.getDesignHandle().findElement("elementName").drop();

}


Attached Image

This works as you would expect, for most outputs. However, when you try this for pdf, while it does drop the correct element when you run the report in pdf, it also drops the element when you run the report in the web viewer. This is because getOutputFormat returns pdf when you run your report with the web viewer.

Attached Image

Attached Image


Luckily, there is a way around this. You also have access to the HttpServletRequest, so if you use a script like the following, in your beforeFactory, the correct format will be returned.

if(reportContext.getHttpServletRequest().getAttribute("attributeBean").format == "pdf"){
	reportContext.getDesignHandle().findElement("elementName").drop();
}


With this method, we now see that the web viewer is actually HTML and the correct element is dropped from the report.

Attached Image

This solution will only work in open-source BIRT, as the HttpServletRequest is not available in the commercial version. The sample report used in this post can be downloaded here.

Filed in drop, xls, html, pdf, web viewer

Last week in the Forums: Calling a Function in BIRT Script Area from HTML Button, Localization in Chart Not Working, and more...

Posted by mwilliams  Icon, 23 January 2012 - 08:20 AM

This blog series takes a look back at the past week in the forums, recalling how active they were and highlights some of the questions asked that seem to frequent the forums or other interesting topics. The site was down for maintenance much of this past week and Monday was a holiday, so the traffic was pretty slow. Still, many great questions and answers were posted. As always, thanks to those users who help answer questions! It is a great help to the community!

Last week's unanswered post was how to use a HTML button to call a function from the report script. The poster wanted to be able to use script in a HTML button to call a function that is declared in their report's initialize script. They know they can create a function within the HTML to call, but wanted to know if they could do this with a function within the BIRT script methods. If anyone has done this or has a suggestion. Please post in the thread!

The next topic I'll cover from last week is datetime localization not working in charts. The poster noticed an issue in 2.5.1 that their localization didn't affect their axis labels in their chart. In a newer version, 2.6.2, it did work. The issue ended up being that setting a format code in the chart wizard messed up the localization. The workaround solution was to apply the formatting in script. The necessary script is shown in the thread.

The last topic I'll cover is about where to find the new features for the latest release. This question gets asked often enough that I thought it would be a good one to cover. To find the newest features, the best place to look is at the project plan pages for BIRT on eclipse.org. You should be able to find all versions and what new features went in to each. You can also find the bugs that were addressed with each version.

Again, this is just a small sample of what went through the forums this past week. For more questions and answers that have been posted, check out the forums. As always, if you have a question, feel free to ask it, and if you see a question you know the answer to or have a similar experience to, feel free to post an answer or comment.

Filed in BIRT, BIRT Exchange, forums, reporting, HTML, script, chart, localization, version features

Page 1 of 1

« May 2013 »

S M T W T F S
1234
567891011
12131415161718
19 20 2122232425
262728293031

My Picture

0 user(s) viewing

0 Guests
0 member(s)
0 anonymous member(s)

Categories

Search My Blog

Twitter