Skip to main content

Viewer Usage

Viewer Usage

Overview

This Viewer is an AJAX based Java EE application that illustrates using the BIRT engine to generate and render report content.

The Web Viewer can be used to generate and render reports, and also supports more interactive features such as table of contents, exporting report content to several formats, client and server side printing, as well as report pagination. The features available will depend on what servlet mapping is used, the settings available in the web.xml file and what values are passed as parameters.

The Example Viewer can also be deployed as an Eclipse plugin in an RCP application.

The Example Viewer also ships with a tag library which can be used to provide report functionality within your existing web applications.

Servlet Mappings

The BIRT Web Viewer consist of two main Servlets, the ViewerServlet and the BirtEngineServlet. These Servlets handle three mappings: ( /frameset, /run, and /preview).

The /frameset mapping renders the report in the full AJAX viewer complete with toolbar, navigation bar and table of contents features. This mapping also generates an intermediate report document from the report design file to support the AJAX based features. eg http://localhost:8080/viewer/frameset?__report=myreport.rptdesign&parm1=value1

The /run mapping runs and renders the report but does not create a report document. This mapping does not supply HTML pagination, TOC or toolbar features, but does use the AJAX framework to collect parameters, support report canceling and retrieve the report output in HTML format. eg http://localhost:8080/viewer/run?__report=myreport.rptdesign&parm1=value1

The /preview mapping runs and renders the report and does not generate a report document, although an existing report document can be used in which case just the render operation occurs. The output from the run and render operation is sent directly to the browser. eg http://localhost:8080/viewer/preview?__report=myreport.rptdesign&parm1=value1

img

Web Viewer Web.xml Settings

The web.xml file contains many settings used to configure the Viewer. These settings are illustrated below.

Attribute

Description

BIRT_VIEWER_LOCALE

This setting sets the default locale for the Web Viewer.

BIRT_VIEWER_WORKING_FOLDER

This is the default location for report designs. If the report design specified in a URL parameter is relative, this path is pre-pended to the report name.

BIRT_VIEWER_DOCUMENT_FOLDER

If a report document parameter (__document) is not used, this is the location that report documents will be generated in. If this setting is left blank, the default value "webapp/documents" will be used. If the__document URL parameter is used and the value is relative the report document will be created in the working folder.

WORKING_FOLDER_ACCESS_ONLY

If this value is set to true, reports will only be searched for, relative to the working folder. This prevents a user from entering a full path to a report. Relative paths below the working folder are accessible.

BIRT_VIEWER_IMAGE_DIR

Specifies the default location to store temporary images generated by the report engine. If this setting is left blank, the default location of webapp/report/images is used.

BIRT_VIEWER_LOG_DIR

Specifies the default location to store report engine log files. If this setting is left blank, the default location of webapp/logs is used.

BIRT_VIEWER_LOG_LEVEL

Sets the report engine log level. Valid values are:
OFF
SEVERE
WARNING
INFO
CONFIG
FINE
FINER
FINEST

BIRT_VIEWER_SCRIPTLIB_DIR

Specifies the default location to place Jar files used by the script engine. These can be Jars used by script engine or jars containing event handlers written in Java. These Jars are appended to the classpath. If this setting is left blank the default value of webapp/scriptlib will be used.

BIRT_RESOURCE_PATH

This setting specifies the resource path used by report engine. The resource path is used to search for libraries, images, and properties files used by a report. If this setting is left blank, resources will be searched for in the same directory as the report.

BIRT_VIEWER_MAX_ROWS

Specifies the maximum number of rows to retrieve from a dataset.

BIRT_OVERWRITE_DOCUMENT

Specifies whether to overwrite the report document every time a report is executed. The default is set to true. Valid values are true and false.

BIRT_VIEWER_CONFIG_FILE

Specifies the location of the viewer.properties file. This file contains various settings used by the viewer.

BIRT_VIEWER_PRINT_SERVERSIDE

This setting specifies whether server side printing is supported. If set to OFF the toolbar icon used for server side printing will be removed automatically. Valid values are ON and OFF.

HTML_ENABLE_AGENTSTYLE_ENGINE

This setting determines how BIRT styles are handled with the HTML emitter. If set to TRUE, the BIRT engine will output the styles directly to the report and depends on the browser to implement the style calculations. If set to FALSE the emitter will use the BIRT style engine to calculate the styles and will output the results directly to the report.

Parameters

The example viewer has a distinction between report parameters and viewer configuration parameters. Report parameters are used by the report designs and configuration parameters affect the appearance and features available to the example Viewer application. In either case these parameters can be passed as URL parameters by entering the &parmname=value syntax, passed in a html form, or passed using the jsp:parm tag. Configuration parameters by default start with two underscore characters "__" prefixed to the parameter name.

Report parameters that are designated in the design as required and are not entered in one of the above methods will cause the viewer to launch a parameter entry dialog box. Additionally the example Viewer tag library contains tags to configure and set parameters as well.

Attribute

Description

__id

A unique identifier for the viewer.

__title

Sets the report title.

__showtitle

Determines if the report title is shown in the frameset viewer. Defaults to true. Valid values are true and false.

__toolbar

Determines if the report toolbar is shown in the frameset viewer. Defaults to true. Valid values are true and false.

__navigationbar

Determines if the navigation bar is shown in the frameset viewer. Defaults to true. Valid values are true and false.

__parameterpage

Determines if the parameter page is displayed. By default the frameset, run and preview mappings will automatically determine if the parameter page is required. This setting will override this behavior. Valid values are true and false.

__report

Sets the name of the report design to process. This can be an absolute path or relative to the working folder (See web.xml settings).

__document

Sets the name for the rptdocument. The document is created when the report engine separates run and render tasks, and is used to support features like table of contents and pagination. This setting can be an absolute path or relative to the working folder (See web.xml settings). If no document parameter is used, a unique document is created in the document folder (see web.xml settings).

__format

Specifies the desired output format, such as pdf, html, doc, ppt, or xls.

__locale

Specifies the locale for the specific operation. Note that this will override the default locale. Order of precedence is as follows:

__locale parameter.

Locale from client browser.

Locale web.xml setting.

Locale for the application server.

__svg

Specifies whether SVG is supported.

__page

Specifies specific page to render.

__pagerange

Specifies page range to render. Eg 1-4,7.

__isnull

Specifies that a report parameter has a null value. Eg __isnull=Myparameter.

__islocale

Specifies whether the parameter is localized.

__masterpage

Indicates that the report master page should be used or not. Valid values are true and false.

__overwrite

This setting if set to true will force an overwrite of the existing report document. This setting will override the initial setting in the web.xml. By default the report document is overwritten anytime the report design is changed.

__bookmark

Specifies a specific bookmark within the report to load. The viewer will automatically load the appropriate page.

__rtl

Specifies whether to display the report in right to left format. This setting defaults to false.

__fittopage

Specifies whether PDF generation should fit content to a page. Valid values are true and false.

__resourceFolder

Specifies the resource folder to use. This setting will override the default setting in the web.xml. The resource folder is used to locate libraries, images, and resource files.

Viewer Directory Structure

The Example Web Viewer has the following directory structure.

img

BIRT POJO Viewer:

If you are installing BIRT 3.7 or higher, The platform, configuration, and plugin directories has been removed from the Viewer. See the BIRT 3.7 Migration Guide for more details.

Most of the directories are configurable using variables set within web.xml. The WEB-INF/platform, webcontent, and WEB-INF/lib directories are exceptions.

The BIRT plugins and associated OSGi configuration files are located in the WEB-INF/platform directory. This directory is hard coded in the Viewer, but allows the application to be deployed in WAR format. When deployed in this manner the Viewer source will create a copy of the platform directory in a directory that is set with the system variable javax.servlet.context.tempdir. Once the platform directory is created the BIRT plugins will be copied to the tempdir and the Platform is then started.

The webcontent directory contains the JavaScript files used for AJAX communications, the JSP fragments used to construct the Viewer instance, image files used by the Viewer, and the cascading style sheets used within the Viewer.

The WEBINF/lib directory contains the required Jars for the Viewer to operate.

Additional Jar files that are used by deployed reports can be placed in the WEB-INF/lib or the scriptlib directories. See the web.xml settings section for additional details.

Viewer Tag Library

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 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 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.

img

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">
</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.

scrolling

Sets the IFRAME scrolling style attribute. Valid values are auto, yes, and no. If isHostPage is true these values are ignored.

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 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

Specifies the target window for the form submit. For example: _blank or parent

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

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.