Wednesday, September 19, 2007

2.2 BIRT Tag Library: Building a Custom Parameter Page

The Web Viewer now contains a tag library that can be used to customize the behavior of the Viewer. This tag library can be deployed by either deploying the viewer as normal or by using the new BIRT Web Deployment project wizard. In addition, if you desire to have BIRT deployed in one context and include the tag library in a separate context this can be done by copying the birt.tld file to your WEB-INF\tlds directory and copying coreapi.jar, modelapi,jar, viewerservlets.jar, engineapi.jar, and com.ibm.icu_3.6.1v20070417.jar from the Viewer libs directory to the new context/web-inf/lib directory. Add the following reference to your web.xml.

<jsp-config>
<taglib>
<taglib-uri>/birt.tld
<taglib-location>/WEB-INF/tlds/birt.tld
</taglib>
</jsp-config>

The following tags are now available:

enlarge

The parameterPage tag can be used to construct your own parameter page before calling the BIRT Viewer. In addition to calling the Viewer several attributes are provided to customize the Viewer appearance and functionality.

For example the following JSP code will present the user with a set of text boxes to enter the two parameters required for the report. The pattern attribute specifies the Servlet mapping to be used and can be set to frameset, run or preview.

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="/birt.tld" prefix="birt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>

<birt:parameterPage id="birtParmPage" reportDesign="TopNPercent.rptdesign"
name="my form"
pattern="frameset"
height="600"
width="800"
format="html"
title="My Viewer Tag"
isCustom="true"
showTitle="true"
showToolBar="true"
showNavigationBar="true"
>
TOP COUNT PARAMETER
<input type="Text" name="Top Count">
<br><br>
TOP PERCENT PARAMETER
<input type="Text" name="Top Percentage">
<br><br>
<input type="Submit" value="Run Report">
</birt:parameterPage>
</body>
</html>

If you wish the BIRT Engine to return the HTML it generates for the parameter you can use the paramDef tag in conjunction with the parameterPage tag.

The following code will call the BIRT engine to populate each level of a cascade.

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="/birt.tld" prefix="birt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<style type="text/css">
.class1 { background-color:#ff0000; color: #ffffff; }
</style>
<body>

Parameter Page 1
<br>
<birt:parameterPage
id="report1"
name="page1"
reportDesign="cascade_report.rptdesign"
isCustom="true"
pattern="frameset">

Cascading Parameter1: <birt:paramDef id="5" name="Country" />
<br><br>
Cascading Parameter2: <birt:paramDef id="6" name="City"/>
<br><br>
Cascading Parameter3: <birt:paramDef id="7" name="Customer" cssClass="class1"/>
<br><br>
<input type="submit" name="submit" value="Sumbit form"/>
<br><br>
</birt:parameterPage>
<br>
</body>
</html>


This code will produce the following output. Notice that the third level is also being customized by using a style.

enlarge

Download the 2.2 build and try out the new tag library.

Monday, July 30, 2007

BIRT Live Day in Las Vegas

Actuate is hosting the first BIRT Live Day on August 15th in Las Vegas. The event consists of 11 technical sessions divided into two tracks on developing with BIRT and deploying BIRT. I'll be giving a session on "Deploying the BIRT Engine." Some of the other topics include integrating BIRT with the Google Web Toolkit, Internationalizing and Localizing reports and End User Interactivity with BIRT - just to give you a flavor. It's part of Actuate's International User Conference, but you can register just for BIRT Live Day if you want for $150.

Full Agenda and Registration details are here.

Thursday, July 19, 2007

Styles Revisited

Its been a while, but after some family commitments, I am finally back at it with BIRT. In April of 2006, I created a post discussing how Styles could be used within BIRT. With the release of 2.2, it is time to revisit CSS Styles in BIRT. The biggest change is that you can now link to a CSS style sheet, the styles do not need to be imported into the report. This is a HUGE improvement.

To take advantage of this feature you go to the outline view, right click on styles and get the following dialog.


The new option allows you to "Use CSS File". When you select this file a dialog that enables you to select a file.


Once you have attached the CSS file, you will then have access to any of the classes in the CSS file to use as styles within your report. But this is just the beginning. All of the major objects and positions within a BIRT report have a default style associated with them. By modifying the default style settings you can change the look of your report without having to set any styles manually.

The best place to start with the pre-defined styles is to start with the visual objects that make up the report the controls. Each control type has a default style associated with it.
  • text
  • label
  • text
  • data
  • image
  • text-data

So adding the following entry in your style sheet will change the default behavior of all text controls to be orange.
.text{
color: orange;
}

In reality, one should be very careful with how many changes are made to the lowest level styles. Changing a property for a basic control style, will change the style for all instance of that control, unless the control specifically over-rides the property. So if you want all of your text to be orange, by all means modify the base control classes. If on the other hand, you want to modify report style by position within the report, then read on. In other words, if you want the header for all of your tables to look one way and the detail to look another, BIRT provides default classes that control that behavior.

Before moving into the full array of BIRT default classes, I want to expose the CSS properties that BIRT supports. The following table documents the properties and the default property values that BIRT uses.

CSS Property Values | Default | Inherit
background-attachment scroll | fixed | inherit

<color>| transparent | inherit
background-image <uri> | none | inherit
background-position [ [ <percentage> | <length> | left | center | right ] [ <percentage> | <length> | top | center | bottom ]? ] | [ [ left | center | right ] || [ top | center | bottom ] ] | inherit
background-repeat repeat | repeat-x | repeat-y | no-repeat | inherit
border-top-color , border-right-color , border-bottom-color , border-left-color <color> | transparent | inherit
border-top-style , border-right-style , border-bottom-style , border-left-style <border-style> | inherit
border-top-width , border-right-width , border-bottom-width , border-left-width <border-width> | inherit
color <color> | inherit
display inline | block | list-item | run-in | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | none | inherit
font-family [[ <family-name> | <generic-family> ] [, <family-name> | <generic-family>]* ] | inherit
font-size <absolute-size> | <relative-size> |<length> | <percentage>| inherit
font-style normal | italic | oblique | inherit
font-variant normal | small-caps |inherit
font-weight normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit
letter-spacing normal | <length> | inherit
line-height normal |<number> | <length> | <percentage> | inherit
margin-right , margin-left <margin-width> | inherit
margin-top , margin-bottom <margin-width> | inherit
orphans <integer> | inherit
padding-top , padding-right , padding-bottom , padding-left <padding-width> | inherit
page-break-after auto | always | avoid | left | right | inherit
page-break-before auto | always | avoid | left | right | inherit
page-break-inside avoid | auto | inherit
text-indent <length> | <percentage> | inherit
text-align left | right | center | justify | inherit
text-decoration none | [ underline || overline || line-through || blink ] | inherit
text-transform capitalize | uppercase | lowercase | none | inherit
white-space normal | pre | nowrap | pre-wrap | pre-line | inherit
widows <integer> | inherit
word-spacing normal | <length>|inherit
vertical-align baseline | sub | super | top | text-top | middle | bottom | text-bottom | <percentage> | <length> | inherit

Most of you are probably familiar with the standard HTML cascade:
Table
tr
td

A td element will inherit from either the table or the row if it has not defined its own value. If you do specify a property value for the td selector, than it will over-ride the values set at both the row and table levels.

BIRT uses its own cascade precedence. Since each of the major objects and functional positions is assigned a default style. The next table shows the precedence used for the BIRT default styles.

Controls

data

image

label

text

text-data
report

page

grid

list

list-header

list-detail

list-footer

list-group-footer-1

. . .

list-group-footer-9

list-group-header-1

. . .

list-group-header-9

table

table-header

table-header-cell

table-detail

table-detail-cell

table-footer

table-footer-cell

table-group-header-1

table-group-header-cell

. . .

table-group-header-9

table-group-footer-1

table-group-footer-cell

. . .

table-group-footer-9
TOC-level-0
. . .
TOC-level-9

So if you want to change the font-family for all of the controls within your report, then you can use the following within your CSS document.

.report{
font-family: sans-serif;
}

If you want the tables in the report to use italics and a serif font, then you would add:
font-family: sans-serif;

.table{
font-style: italics;
font-family: serif;
}


As you can see, you can control the behavior for headers, detail sections, and footers for list and tables. In addition, each of the group headings can use its own style up to 9 levels deep. In the previous article, I provided a CSS document that was setup to take advantage of this feature. Unfortunately, the Default Style Names have changed between 2.1 and 2.2. I have revised the style-sheet to work with the new default style names.

.report {
font-family : sans-serif;
font-size : medium;
font-weight : bold;
color : #FFFFE0;
}
.table-group-header-1 {

background : #0B285B;
border-bottom : double;
border-top : solid;
border-top-width : thin;
border-color : #FFF8DC;
}
.table-group-header-2 {
background : #13449B;
border-bottom : double;
border-top : solid;
border-top-width : thin;
border-color : #FFF8DC;
font-size : small;
}
.table-header {
background : #6495ED;
border-bottom : double;
border-top : solid;
border-top-width : thin;
border-color : #483D8B;
}
.table-detail {
background : #F0F8FF;
font-size : small;
font-weight : bold;
color : #4682B4;
}
.table-footer {
background : #6495ED;
border-top : double;
border-bottom : solid;
border-bottom-width : thin;
border-color : #483D8B;
font-size : x-small;
}

I am hopeful that in the next edition, I can take a look at adding a bit of code to the report that will do more to automatically assign styles to reports, even if you are using custom styles. I will let you know when I get it done.

Friday, June 29, 2007

BIRT 2.2 Released

In conjunction with Eclipse’s Europa release BIRT 2.2 is now available. This release represents a significant improvement in features and functionality, including over 200 enhancements. Some of the more significant features include a new Cross Table element, that when constructed with the new data cubes technology allows the creation of dynamic tables with support for column and row aggregation, new emitters for XLS, PPT, DOC, and postscript formats, a new web service data access driver, improved charting with the addition of six new chart types, new web deployment wizards, and tag libraries for the BIRT web viewer and charting engine.

To read more about the new and improved features in BIRT 2.2 take a look at the New and Notable- BIRT 2.2

Monday, June 04, 2007

BIRT Release Candidate 0 New and Notable

With this release of BIRT many new features have been added. The Dynamic Cross Table element is now available as well as a new Web Service ODA. These features and many others are described in the New and Notable for BIRT 2.2 RC0. As part of documenting these features we have dropped a couple new examples into the wiki. For example:

Crosstab Example.

This example is available
here and is an example of using the new BIRT Cube technology in conjunction with the new Cross Table Element. In previous versions of BIRT cross tables could be created, but the number of vertical columns had to be known beforehand. This is no longer necessary, as this example illustrates.

Be sure to download the latest Release Candidate of BIRT and give the new features a try.

Tuesday, May 15, 2007

JFire and BIRT

JFire is a comprehensive Open Source ERP solution that uses BIRT for reporting. A couple of weeks ago at the Eclipse Forum Europe conference, I had the opportunity to look at what they are doing with BIRT. Not only do they include BIRT designs, they have gone as far as to include a customized version of the designer within their product. Alex Bieber demonstrated some of these customizations, including a workflow parameter entry builder and a customized editor for creating resource files for BIRT.

Below is a screenshot of the parameter workflow builder.



This feature effectively collects parameters in a cascaded fashion and ultimately passes the final value onto a BIRT report for generation. As displayed in the screenshot above, this builder is available as a new tab on the modified BIRT designer.

To read more on these customizations, go to the JFire site or checkout the JFire wiki entries for these features.

JFireReporting Parameter Acquisition

JFireReporting Localisation

Thursday, May 03, 2007

2nd Annual Open Source BI Survey

A survey is being conducted which I thought may be of interest to BIRT report developers. The results will provide valuable insights into awareness and trends in Open Source software adoption and usage, and as a participant you have the opportunity to ensure your opinions and experiences are included in the analyses. This survey is now in its second year so comparative results will also give some key insights into how perceptions, trends and adoption levels have changed in that period.


In return for taking part, you will receive a summary of the results from the full study. You will also have a chance of receiving one of five $100 Amazon vouchers. This survey will take about 5 minutes of your time. To get started, click here.