Академический Документы
Профессиональный Документы
Культура Документы
Report Customization
Virgil Dodson
Evangelist, BIRT Exchange
July 3, 2008
Java Forum Stuttgart
1
Actuate Corporation © 2007
Open Source Reporting: Eclipse BIRT
1,000
• Web-centric design metaphor
800 • Open Source with rapid adoption
600 • Standards based & highly extensible
400
• Open XML design format
• Build community and ecosystem
200
0
1H 05 2H 05 1H 06 2H 06 1H 2007 2H 2007
2
Actuate Corporation © 2007
High Level BIRT Architecture
XML Report
Report Data Document
Design
Data
3
Actuate Corporation © 2007
BIRT Report Designer
What
What is
is the
the BIRT
BIRT Report
Report Designer?
Designer?
•• Open
Open source
source based
based and
and highly
highly extensible
extensible
•• Modern,
Modern, web-page
web-page design
design metaphor
metaphor
•• Easy
Easy to
to use
use and
and powerful
powerful
•• Library
Library and
and template
template components
components
•• Scripting
Scripting in
in Java
Java and
and JavaScript
JavaScript
4
Actuate Corporation © 2007 •• Leverages
Leverages thethe powerful
powerful Eclipse
Eclipse IDE
IDE
Agenda
• Report Scripting
• Libraries and Templates
• I18N and Localization
5
Actuate Corporation © 2007
Report Scripting
6
Actuate Corporation © 2007
What is Scripting?
7
Actuate Corporation © 2007
Why use scripting?
• Maximum Flexibility
• Data is rarely is the perfect format
• Business rules are rarely an exact science
• Use for Exception handling
8
Actuate Corporation © 2007
What can be done with Scripting?
Mix and Match! – You can use both Java and JavaScript Events… The
JavaScript event overrides the Java event if the same event exist twice.
10
Actuate Corporation © 2007
Events Overview
11
Actuate Corporation © 2007
Engine Task Processes
12
Actuate Corporation © 2007
Engine Task Processes (cont.)
13
Actuate Corporation © 2007
BIRT Processing Phases
14
Actuate Corporation © 2007
Preparation Phase
15
Actuate Corporation © 2007
Generation Phase
16
Actuate Corporation © 2007
Presentation Phase
17
Actuate Corporation © 2007
BIRT Event Types
• Parameter events
• ReportDesign events
• Data Source/Set events
• ReportItem events
• Each event type has one or more events that will fire during report
processing.
18
Actuate Corporation © 2007
Parameter Events
• validate()
• Used for extra validation or modifying parameter value
• First event triggered for reports with parameters
After user enters parameter value
Before rest of report events run
• Only available in JavaScript
• Expects true or false returned
true – process as normal
false – throw parameter not set exception
19
Actuate Corporation © 2007
Report Design Events
20
Actuate Corporation © 2007
Data Source/Set Events
• All data sources and data sets have a common set of event handlers
• A scripted Data Source has two additional event handlers
• A scripted Data Set has three additional event handlers
• Data source/set events are fired prior to being used on a data bound
item.
• If the data is not used on a report, these events will not fire
• Not advisable to write event handlers that rely on the data set event
firing order.
21
Actuate Corporation © 2007
Data Source Events
• beforeOpen()
• open() – only for Scripted Data Sources
• afterOpen()
• beforeClose()
• close() - only for Scripted Data Sources
• afterClose()
22
Actuate Corporation © 2007
Data Set Events
• beforeOpen()
• open() – only for Scripted Data Sets
• afterOpen()
• fetch() – required for Scripted Data Sets
• onFetch() – as each row of data is retrieved
• beforeClose()
• close() - only for Scripted Data Sources
• afterClose()
23
Actuate Corporation © 2007
ReportItem Events
24
Actuate Corporation © 2007
Preparation Phase
25
Actuate Corporation © 2007
Preparation Phase
RunTask RunAndRenderTask
Parameter
Parameter Parameter
Parameter
Parameter
validate() Parameter
validate()
validate()
validate() validate()
validate()
ReportDesign ReportDesign
initialize() initialize()
ReportItem
ReportItem ReportItem
ReportItem
ReportItem
onPrepare() ReportItem
onPrepare()
onPrepare()
onPrepare() onPrepare()
onPrepare()
ReportDesign ReportDesign
beforeFactory() beforeFactory()
ReportDesign
beforeRender()
26
Actuate Corporation © 2007
Generation Phase
27
Actuate Corporation © 2007
Generation Phase
RunTask RunAndRenderTask
MasterPage Data MasterPage Data
Events Events
MasterPage MasterPage
onPageBreak() onPageBreak()
Report
ReportBody
BodyData Report Body Data
Report BodyData
Events Data Report
ReportBody
BodyData
Events Data
Events
Events Events
Events
Report
ReportItem
Item Report
ReportItem
Item Report
ReportItem
Item
Report
onCreate() Item Report
onCreate() Item Report
onRender() Item
onCreate()
onCreate() onCreate()
onCreate() onCreate()
onCreate()
Report
ReportBody
Body Report
ReportBody
Body
Report Body
onPageBreak() Report Body
onPageBreak()
onPageBreak()
onPageBreak() onPageBreak()
onPageBreak()
28
Actuate Corporation © 2007
Report Element Processing
• Processing is Iterative
• Nested Elements are processed
before moving to the next element
29
Actuate Corporation © 2007
onPageBreak Event
30
Actuate Corporation © 2007
Row Event Order Processing
RunTask
Row.onCreate
RunAndRenderTask
Repeat for every cell in a row Row.onCreate
Cell.onCreate Row.onRender
Repeat for every item in a cell Repeat for every cell in a row
Item.onCreate Cell.onCreate
Cell.onRender
Row.onRender Item.onCreate
Item.onRender
Repeat for every cell in a row
Cell.onRender
31
Actuate Corporation © 2007
Table or List Order Processing
DataSet.beforeOpen
DataSet.afterOpen
DataSet.onFetch
DataSet.onFetch
Table.onCreate
For every group level in the table
Table.onRender
Process Group Header Row(s)
Cell.onRender
32
Actuate Corporation © 2007
Completion of Generation Phase
33
Actuate Corporation © 2007
Presentation Phase
34
Actuate Corporation © 2007
BIRT Scripting in
Action!
35
Actuate Corporation © 2007
Libraries and Templates
36
Actuate Corporation © 2007
What are Libraries?
37
Actuate Corporation © 2007
What are Templates?
38
Actuate Corporation © 2007
Difference between Libraries and
Templates
39
Actuate Corporation © 2007
When to use Templates and Libraries?
40
Actuate Corporation © 2007
Benefits of using Libraries and Templates
• Save time
• Reduce errors
• Reduce complexity
• Enforce standards
• More responsive to reporting requests
41
Actuate Corporation © 2007
BIRT Libraries in
Action!
42
Actuate Corporation © 2007
I18N and Localization
43
Actuate Corporation © 2007
Introduction
44
Actuate Corporation © 2007
Localization Process
Each file contains the The report design uses the The report output will the
resource keys, Greeting and resource keys localized strings depending
Thanks, and the localized string in a label element upon the locale of the user
Resources_fr_FR.properties
Bonjour
Greeting=Bonjour
Thanks=Merci Merci
fr_FR
Resources_en_US.properties Greeting
Hello
Greeting=Hello
Thanks
Thanks=Thank you Thank you
en_US
Resources_es_ES.properties
Hola
Greeting=Hola
Thanks=Gracias Gracias
es_ES
45
Actuate Corporation © 2007
Resource Files
46
Actuate Corporation © 2007
Using a Resource File
47
Actuate Corporation © 2007
Using a Resource File – cont’d
48
Actuate Corporation © 2007
Using a Resource File – cont’d
49
Actuate Corporation © 2007
Using a Resource File – cont’d
50
Actuate Corporation © 2007
Previewing a Report in Different Locales
51
Actuate Corporation © 2007
BIRT I18N in Action
52
Actuate Corporation © 2007
New and Updated Publications
53
Actuate Corporation © 2007
BIRT Exchange Community Site
www.birt-exchange.com
Download
• Documentation
• Software
Share Knowledge
• Reports, Code, Tips
• Forums
Find
• Search, Sort
• Rate, Comment
54
Actuate Corporation © 2007