Home > Articles

This chapter is from the book

Events overview

When writing event handlers, understanding the event order is imperative. The order in which events fire depends on several factors. These factors include which BIRT processing phase is executing, the engine task executing the process, and what event type is processing.

Engine task processes

The scripting chapters make continuous reference to engine task processes. This section provides an overview of what these processes are and how they affect scripting.

The Report Engine that executes reports is task-oriented and provides three tasks related to the execution and rendering of reports. These tasks are RunAndRenderTask, RunTask, and RenderTask.

The RunAndRenderTask uses one process to open the report design and produce a specific output, such as PDF. The RunTask opens a report design and executes the report producing a report document file with a .rptdocument extension. This report document is an intermediate binary file that can then be used by a RenderTask to produce a report output type, such as HTML, PDF, PPT, PS, Word, or XLS. The RenderTask opens a report document (.rptdocument) and renders the appropriate output format. This task can be executed any time after a RunTask. This task can even occur on a separate system.

BIRT Report Designer uses the report engine to show a preview of a report. Selecting Preview in the Editor launches a RunAndRenderTask to produce the report. Selecting any other previewing option in BIRT Report Designer toolbar launches a RunAndRenderTask to produce the output, with the exception of the Run report in BIRT Web Viewer, which produces the report using a RunTask followed by a RenderTask.

The tasks RunTask and RenderTask can be used when the tasks need to occur at separate times or on separate systems. Using separate run and render tasks therefore requires two processes to run and render a report to a particular output format.

When RunAndRenderTask processes a report, the event firing order is different from the RunTask and RenderTask are used as two separate processes. The differences in processing are discussed throughout these chapters.

The following sections describe how the report engine processes reports in the BIRT Report Designer environment.

BIRT Web Viewer

The example BIRT Web Viewer application is a J2EE application that encapsulates the report engine to produce reports. This viewer contains three Servlet mappings used to generate reports. These are the frameset, run, and preview mappings.

In the example web viewer, two processes, RunTask and RenderTask, generate and render to the output format to create a report document. Selecting the Export report icon in the Web Viewer toolbar initiates a RenderTask to execute on the current report document.

BIRT processing phases

The BIRT services for generating and presenting report data create a report during the following processing phases:

  • Preparation

    RunTask or RunAndRender Task prepare the report items for execution.

  • Generation

    RunTask or RunAndRender Task create an instance of each report item, connect to the data source, execute the data sets, and process the data to produce the report.

  • Presentation

    RenderTask or RunAndRender Task select the correct emitters to produce the output specified for the report.

The RunTask handles the preparation and generation phases and the Render Task handles the presentation phase. RunAndRenderTask handles all phases of report processing. The types of events and the order in which these events fire depends on the processing phase currently executing in an engine task.

BIRT event types

BIRT supports the following types of events:

  • Parameter
  • Report design
  • Data source and data set
  • Report item

Each event type has a series of events that fire during report processing.

Parameter events

BIRT currently supports two parameter level events that can be used to customize the parameter selection choices and default values before the parameter entry box is displayed. In addition, BIRT supports one parameter level event that is called after the parameters have been selected. These events are summarized in Table 7-1. These events are currently available only in JavaScript. Parameter events fire only if the report contains parameters.

Table 7-1. Parameter events

Event

Description

getDefaultValueList

Sets the parameter's default value. If the parameter is set to allow multiple values, this script should return an array of values that will then be preselected in the parameter entry box. This event fires first.

getSelectionValue List

Returns a single value or an array of values. This event fires before the parameter entry box displays for parameters presenting a list of values. Simple text parameters do not call this event.

validate

This event fires after the user selects the report parameters and before the initialize event. This event fires for each parameter and returns a value of true or false. Returning false throws an exception that states which parameter failed validation. Returning true processes the report normally.

Listing 7-1 provides an example of getDefaultValueList and getSelectionValueList event handlers for a parameter formatted as a list box. The array dSLArray contains four values that a report user can select. The array dVLArray contains two values that are the default values of the parameter. These values are selected in the list of available values when the user runs the report.

Listing 7-1. Example event handlers for a parameter formatted as a list box

//getDefaultValueList
var dVLArray = [];
dVLArray[0]= "10104";
dVLArray[1] = "10108";
dVLArray;

//getSelectionValueList
var dSLArray = [];
dSLArray[0]= "10101";
dSLArray[1]= "10104";
dSLArray[2]= "10105";
dSLArray[3] = "10108";
dSLArray;

The getDefaultValueList can be useful to provide date parameters as well.

If changes to the parameter are necessary after a user enters a parameter or if extra parameter validation is required, write an event handler for the validate event. The following example shows a validate script for a string parameter:

params["MyParameter"].value = "Something Else";
true;

Report design events

Report design events fire for all reports. Table 7-2 describes these events. The events support event handlers to provide additional processing of the report.

Table 7-2. Report design events

Event

Description

initialize

Fires every time a task accesses the report design (.rptdesign) or the report document (.rptdocument). This event occurs once when using RunAndRenderTask. When the processing phases run separately, RunTask triggers once for the generation phase and RenderTask triggers once for every render operation. Displaying the first page of a report in the presentation phase and using the page navigation control to access a new page also triggers this event handler.

beforeFactory

Fires just prior to the generation phase after the elements in the report have been prepared in the preparation phase. This event handler fires only once. Use beforeFactory( ) when modifications to the report design are required before execution.

beforeRender

Fires just prior to the presentation phase and is called for every render operation. In the RunAndRender task, this event occurs once just after the beforeFactory event.

afterFactory

Fires at the conclusion of the generation phase and fires only once. If using a RunTask or RunAndRenderTask, this event is the last one fired. If using a RenderTask, this event does not execute.

afterRender

Fires at the conclusion of the presentation phase for a specific render operation. If using a single RunAndRenderTask process, this event is called only once. If using separate RunTask and RenderTask processes, this event fires for every render operation.

onPageStart

Fires prior to placing content on a specific page and supports the use of page-level variables to modify the page. This event fires only when processing phases run separately, for example, a RunTask followed by a RenderTask. This event fires prior to the onPageBreak events for the individual elements to be placed on the page. This event is also available on the master page.

onPageEnd

Fires after all the onPageBreak events have fired for the content to be placed on a page and prior to evaluating the autotext items for the page. This event is also available on the master page.

Types of data source and data set events

There are several kinds of data sources and data sets. A data source can be a flat file, a JDBC data source, a scripted data source, a web services data source, or an XML data source. All data sources have a common set of event handlers. A scripted data source has two additional event handlers.

Data set events can be called multiple times to support multipass aggregation and data set sharing. It is not advisable to write event handlers that rely on the data set event firing order. An additional issue is that data set event handlers may only be called once because of data set caching.

Table 7-3 describes the data source events.

Table 7-3. Data source events

Event

Description

beforeOpen

This event is most often used to modify public properties of the data source, including database URL, username, password, driver class and JNDI URL. This event fires only once, before the connection to the data source opens event, when the connection uses multiple data sets. Fires prior to opening a connection to a data source.

afterOpen

Fires after the connection to the data source opens.

beforeClose

Fires at the conclusion of the generation phase, just prior to closing the data source connection.

afterClose

Fires after the data source connection closes.

open

Fires only for a scripted data source, providing a location for the developer to set up a connection to an external source.

close

Fires only for a scripted data source, providing a location for the developer to close a connection to an external source.

Data source and data set events fire in the generation phase prior to the onCreate event of the report item that uses them. Data set events can fire several times. The event order is covered in more detail later in this chapter. Table 7-4 describes the data set events.

Table 7-4. Data set events

Event

Description

beforeOpen

Fires prior to opening a data set and used most often to modify public properties of the data set. For example, when using a JDBC data set, the query text can be altered using this event. This event fires for every report item bound to the data set. If two tables use the same data set, the data set is called twice, resulting in this event firing twice. BIRT 2.6 allows report items to be bound to other report items, in which case the data set is called only once, resulting in the event triggering only once. Data set caching options continue to be added which affect how often data source and data set events fire.

afterOpen

Fires after the data set opens.

onFetch

Fires as the data set retrieves each row of data. This event fires for all rows of data before the onCreate event for the particular report item that uses the data set.

beforeClose

Fires before closing the data set after creating the report item that uses the data set.

afterClose

Fires after the data set closes.

open

Fires for a scripted data set, providing a location for the developer to set up a data set.

fetch

Fires for a scripted data set, providing a location for the developer to populate rows from the scripted data set.

close

Fires for a scripted data set, providing a location for the developer to close the set.

Data source and data set events fire prior to being used on a data bound item. If the data set is never used in the report, the data source and data set are never called. A scripted data set is a data set that accesses a scripted data source. A non-scripted data set is one that accesses a standard data source. Use the scripted data source and data set to write custom code to retrieve data values.

Scripted data source events

A scripted data source contains the afterOpen, afterClose, beforeOpen, and beforeClose events common to all data sources, and open and close events. Use the event handlers for the open and close events to perform the actions of opening and closing the data source.

Scripted data set events

A scripted data set contains the afterOpen, afterClose, OnFetch, beforeOpen, beforeClose, open, close, and fetch events. Use the event handlers for the open and close events to perform the actions of opening and closing the data set. Use the fetch method to fetch a row from the data source. Using a scripted data set requires an event handler to be written for the fetch event.

ReportItem events

ReportItem events trigger for report items that are placed in the report. Most items support writing event handlers for the events listed in Table 7-5.

Table 7-5. Report item events

Event

Description

onPrepare

Fires at the beginning of the preparation phase before data binding or expression evaluation occurs. This event is useful for changing the design of the item prior to generating the item instance.

onCreate

Fires at the time the generation phase creates the element. This event is useful when a particular instance of a report item needs alteration.

onRender

Fires in the presentation phase. This event is useful for operations that depend on the type or format of the output document.

onPageBreak

Fires for all report items currently on the page when the page break occurs. Not all report items support the onPageBreak event.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020