BIRT Developer Center Download

BIRT with JSP


BIRT Viewer Tag Library

The Sample Viewer 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 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_version.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-uri>
<taglib-location>/WEB-INF/tlds/birt.tld</taglib-location>
</taglib>
</jsp-config>

Using this approach reports are referenced in relation to the BIRT Sample Viewer not the new context.

The Viewer tag library contains five tags param, paramDef, parameterPage, report and viewer. Each tag has multiple attributes that control the behavior of the Viewer.

BIRT-with-JSP-1

Example JSP

<%@ 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">
<title>Insert title here</title>
</head>
<body>
<birt:viewer id="birtViewer" reportDesign="TopNPercent.rptdesign"
pattern="frameset"
height="450"
width="700"
format="html"
baseURL="/birt"
></birt:viewer>
</body>
</html>

The viewer Tag Attributes

Attribute Description
id A unique identifier for the viewer.
pattern The Viewer tag supports either run or frameset, which matches the standard viewer servlet mappings. Frameset is used by default.
baseURL The baseURL is used to determine the location of the Viewer application. If the tags are used in the same context as the BIRT viewer this attribute is not required. If the tag library is used in a separate context but in the same application server, this setting may contain a value such as baseURL=/ WebViewerExample.
title Sets the title for the report container page.
isHostPage If this value is set to true the viewer tag will occupy the entire page. The default value is false, which allows multiple reports to be contained in one JSP Page.
position Sets the IFRAME position style attribute. Valid values are static, absolute, relative and fixed. If isHostPage is true these values are ignored.
style Sets the style for the report container. If isHostPage is true this value is ignored.
height Sets the Height of the IFRAME in pixels. If isHostPage is true this value is ignored.
width Sets the Width of the IFRAME in pixels. If isHostPage is true this value is ignored.
top Sets the top of the IFRAME in pixels. If isHostPage is true this value is ignored.
left Sets the left of the IFRAME in pixels. If isHostPage is true this value is ignored.
frameborder Specifies whether or not to display a border around the IFRAME. Valid values are yes or no. If isHostPage is true this value is ignored.
reportDesign Specifies the name of the report design file. This setting can be relative or set to a full path, or a URL.
reportDocument Sets the name of the report document file. This setting can be relative or set to a full path, or a URL. If using a URL it must be a file URL. File://.
reportletId Specifies the instance id of the portion of the report to be displayed. Note this only works with the run pattern and a reportDocument setting.
bookmark Specifies which bookmark to load within the report. For example, adding a table of contents and specifying the TOC entry will load the page containing that entry.
locale Specifies the locale for the report.
svg Specifies where SVG for charts is supported.
format Specifies the output format, such as pdf, html, or xls.
rtl Sets the right to left flag. By default this is false.
pageNum Displays a specific page within the report.
pageRange Displays a specific page range within the report. For example 2-5, 12.
resourceFolder Specifies the resource folder, which contains libraries and images. This is usually specified in the Web.xml, but this parameter will override that value.
forceOverwriteDocument Specifies whether the report document that is created is overwritten. Only valid with the frameset mapping.
showToolBar When using the Viewer tag with the frameset pattern, this setting determines if the toolbar is displayed.
showNavigationBar When using the Viewer tag with the frameset pattern, this setting determines if the navigation bar is displayed.
showTitle When using the Viewer tag with the frameset pattern, this setting determines if the report title is displayed.
showParameterPage When using the Viewer tag, this setting determines if the parameter page is displayed.

The report Tag Attributes

Attribute Description
id A unique identifier for the viewer.
baseURL The baseURL is used to determine the location of the Viewer application. If the tags are used in the same context as the BIRT viewer this attribute is not required. If the tag library is used in a separate context but in the same application server, this setting may contain a value such as baseURL=/ WebViewerExample. The reportContainer attribute must be set to iframe if this attribute is used.
isHostPage If this value is set to true the viewer tag will occupy the entire page. The default value is false, which allows multiple reports to be contained in one JSP Page.
scrolling Sets the DIV/IFRAME scrolling style attribute. Valid values are auto, yes, and no. If isHostPage is true these values are ignored.
position Sets the DIV/IFRAME scrolling style attribute. Valid values are auto, yes, and no. If isHostPage is true these values are ignored.
position Sets the DIV/IFRAME position style attribute. Valid values are static, absolute, relative and fixed. If isHostPage is true these values are ignored.
style Sets the style for the report container. If isHostPage is true this value is ignored.
height Sets the Height of the IFRAME in pixels. If isHostPage is true this value is ignored.
width Sets the Width of the IFRAME in pixels. If isHostPage is true this value is ignored.
top Sets the top of the IFRAME in pixels. If isHostPage is true this value is ignored.
left Sets the left of the IFRAME in pixels. If isHostPage is true this value is ignored.
frameborder Specifies whether or not to display a border around the IFRAME. Valid values are yes or no. If isHostPage is true this value is ignored. reportContainer must be set to iframe.
reportDesign Specifies the name of the report design file. This setting can be relative or set to a full path, or a URL.
reportDocument Sets the name of the report document file. This setting can be relative or set to a full path, or a URL. If using a URL it must be a file URL. File://. Note that a report document will not be created, but if the reportDocument exist it will be rendered.
reportletId Specifies the instance id of the portion of the report to be displayed. Note this only works with the run pattern and a reportDocument setting.
bookmark Specifies which bookmark to load within the report. For example, adding a table of contents and specifying the TOC entry will load the page containing that entry.
locale Specifies the locale for the report.
svg Specifies where SVG for charts is supported.
format Specifies the output format, such as pdf, html, or xls.
rtl Sets the right to left flag. By default this is false.
pageNum Displays a specific page within the report. Report document must already exist.
pageRange Displays a specific page range within the report. For example 2-5, 12. Report Document must already exist.
resourceFolder Specifies the resource folder, which contains libraries and images. This is usually specified in the Web.xml, but this parameter will override that value.
showParameterPage When using the report tag, this setting determines if the parameter page is displayed. If reportContainer is set to div, this setting is ignored and the parameter page is not displayed.
reportContainer Specifies if the report is rendered in an IFRAME or a DIV element. This attribute affects other attributes.

The param Tag Attributes

Attribute Description
id A unique identifier for the viewer.
name Specifies the report parameter name. This must match the design file.
pattern Specifies the report parameter pattern format. If isLocale is false, this value is ignored.
isLocale Specifies whether the report parameter value is a locale/format related string. Valid values are true or false.
value Sets the value for the report parameter. If this is left blank the default value for the parameter is used.
displaytext Set the display text for the parameter.

The parameterPage Tag Attributes

Attribute Description
id A unique identifier for the viewer.
name Specifies the report parameter page name. This attribute is used to create a form and is required if using the isCustom attribute. This attribute must be unique.
isCustom Indicates whether the default BIRT parameter page is used or a custom page. Valid values are true and false.
pattern The parameterPage tag supports run, frameset, and preview mappings. Frameset is used by default.
baseURL The baseURL is used to determine the location of the Viewer application. If the tags are used in the same context as the BIRT viewer this attribute is not required. If the tag library is used in a separate context but in the same application server, this setting may contain a value such as baseURL=/ WebViewerExample.
target Sets the title for the report container page.
title Sets the title for the report container page.
scrolling Sets the IFRAME scrolling style attribute. Valid values are auto, yes, and no
position Sets the IFRAME position style attribute. Valid values are static, absolute, relative and fixed.
style Sets the style for the report container
height Sets the Height of the IFRAME in pixels.
width Sets the Width of the IFRAME in pixels.
top Sets the top of the IFRAME in pixels.
left Sets the left of the IFRAME in pixels.
frameborder Specifies whether or not to display a border around the IFRAME. Valid values are yes or no. If isCustom is true this value is ignored.
reportDesign Specifies the name of the report design file. This setting can be relative or set to a full path, or a URL.
reportDocument Sets the name of the report document file. This setting can be relative or set to a full path, or a URL. If using a URL it must be a file URL. File://.
reportletId Specifies the instance id of the portion of the report to be displayed. Note this only works with the run pattern and a reportDocument setting.
bookmark Specifies which bookmark to load within the report. For example, adding a table of contents and specifying the TOC entry will load the page containing that entry.
locale Specifies the locale for the report.
svg Specifies where SVG for charts is supported.
format Specifies the output format, such as pdf, html, or xls.
rtl Sets the right to left flag. By default this is false.
resourceFolder Specifies the resource folder, which contains libraries and images. This is usually specified in the Web.xml, but this parameter will override that value.
forceOverwriteDocument Specifies whether the report document that is created is overwritten. Only valid with the frameset mapping.
showToolBar When using the Viewer tag with the frameset pattern, this setting determines if the toolbar is displayed.
showNavigationBar When using the Viewer tag with the frameset pattern, this setting determines if the navigation bar is displayed.
showTitle When using the Viewer tag with the frameset pattern, this setting determines if the report title is displayed.

The paramDef Tag Attributes

Attribute Description
id A unique identifier for the parameter control.
name Specifies the report parameter name. This must match the parameter name in the report.
isCustom Indicates whether the default BIRT parameter page is used or a custom page. Valid values are true and false.
pattern Specifies the report parameter pattern format. If isLocale is false, this value is ignored.
value Sets the value for the report parameter. If this is left blank the default value for the parameter is used.
displaytext Set the display text for the parameter.
isLocale Specifies whether the report parameter value is a locale/format related string. Valid values are true or false.
title Specifies the title attribute of the parameter control.
cssClass Sets the CSS class attribute of the parameter control.
style Specifies the style for the parameter control.

JavaScript API

If you’re using the BIRT Viewer Toolkit or BIRT iHub, you have access to Actuate’s JavaScript API (JSAPI). This allows you to easily embed BIRT content into JSP pages with simple JavaScript.

Sample JSAPI code for embedding the Actuate Viewer into JSP:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text
/html;charset=utf-8" />
<title>Viewer Page</title>
</head>
<body onload="init( )">
<div id="viewerpane">
<script type="text/javascript" language="JavaScript"
src="http://localhost:8700/iportal/jsapi"></script>

<script type="text/javascript" language="JavaScript">

function init( ){
actuate.load("viewer");
actuate.initialize( "http://localhost:8700/iportal", null, null, null, runReport);
} function runReport( ) {
var viewer = new actuate.Viewer("viewerpane");
viewer.setReportName(“myReport.rptdesign");
viewer.submit(callback);
}
</script>
</div>
</body>
</html>

For more about the JSAPI, see either the BIRT Viewer Toolkit or BIRT iHub deployment guide.