Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse BIRT Report Developer Guide
Previous Page Home Next Page

Previous Next

Using Java to Write an Event Handler

Creating a Java event handler is slightly more complex than creating a JavaScript event handler. You cannot simply enter Java code directly in the BIRT Report Designer.

To create a Java event handler class, you must compile the source for the Java class and make certain that the class is visible to BIRT. Creating a Java event handler for BIRT is simplified, however, by the fact that Eclipse is a robust Java development environment and supports integrating a Java project with a BIRT project.

How to create an event handler class and add it to the Java project

This section describes the process for using the Eclipse Java development environment to create an event handler class for a scriptable BIRT element.

1
Select your Java project and choose File PropertiesJava Build PathLibraries. Java Build Path appears, as shown in Figure 23‑1.

Figure 24-1 Adding a JAR file to the compiler’s classpath

2
Select your Java project and choose File NewOther. Select a wizard appears.

Figure 24-2 The Select a wizard dialog

Figure 24-3 New Java Class

Figure 23‑3
4
Navigate to the folder where you want the Java source file to reside by choosing the Browse button beside Source Folder.

Figure 24-4 Superclass Selection

Figure 23‑4
9
In Choose a type, type the name of the adapter class for the ROM element. For example, enter Label EventAdapter for the Label element. Choose OK. New Java Class reappears.

Figure 24-5 The Java editor

Figure 23‑5
11
Add the event handler method for your new event handler class. Figure 23‑6 shows the addition of an onPrepare( ) method that sets the background color of the label to red.

Figure 24-6 The onPrepare( ) method in the Java editor

Figure 23‑6
The onPrepare( ) method in the Java editor

How to associate a Java class with a report element

The example in this procedure makes the following assumptions:

Figure 24-7 Selecting a report element

2
In Property Editor for the selected report element, select Event Handler and enter the fully qualified name of the event handler class, as shown in Figure 23‑8.

Figure 24-8 The event handler class name

 


(c) Copyright Actuate Corporation 2009

 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire