Professional Documents
Culture Documents
Jasper Reports
APplus.50.TB.JasperReports.07/2013.002.E
The information and data contained in this document can be changed without any prior notice. No part of this documentation
may be copied or transferred for any purposes – whether electronically or mechanically - without express written consent of
Asseco Solutions AG.
© Copyright 2013 Asseco Solutions AG, Karlsruhe (Germany)
All Rights Reserved.
APplus.50.TB.JasperReports.07/2013.002.E
Content
JasperSoft Products 9
JasperSoft Capabilities...................................................................................................... 9
JasperReports.................................................................................................................10
iReport – Graphical Report Designer..................................................................................11
JasperServer – Interactive Reporting Server.......................................................................12
Comparison between Open Source and Professional Eition ...................................................13
JasperReports Architecture 15
Servers..........................................................................................................................15
APplus Specific Components and Extensions .......................................................................16
Deployment of APplus Specific Components .......................................................................17
Run Time and Design Time View .......................................................................................18
Run Time ..............................................................................................................18
Design Time ..........................................................................................................22
Jasper Report Life Cycle...................................................................................................24
Authoring 55
Document Bands (Sections) .............................................................................................55
Fonts.............................................................................................................................57
Styles............................................................................................................................57
Scriptlets and Utility Classes.............................................................................................58
Subreports .....................................................................................................................58
APplus Requirements of Subreport ...........................................................................59
Compiling Subreports .............................................................................................61
Tables ...........................................................................................................................61
Using Bands For Modeling Tables..............................................................................62
Using Frames as a Row Element...............................................................................63
Conditional Displaying or Hiding Columns ..................................................................63
APQE - Query Executer and Query Language ......................................................................64
Report Parameters ..........................................................................................................64
$P!{paramName} Syntax........................................................................................65
APplus Internal or Reserved Parameters....................................................................66
Custom or User Parameters .....................................................................................72
Organization Of the Repository .........................................................................................73
Difference between iReport and JasperServer repository .............................................75
Naming Convention .........................................................................................................76
Naming Convention of Reports.................................................................................76
Documents, Lists, Out.............................................................................................76
Statistical Analysis .................................................................................................76
Examples ..............................................................................................................77
Report Types..................................................................................................................77
Standard Report Templates ..............................................................................................78
Styles 103
Creating a New Style .....................................................................................................103
Conditional Styles .........................................................................................................104
Reusing Styles..............................................................................................................105
The Styles Library ................................................................................................105
The Style Template ..............................................................................................106
APplusStyles Template..........................................................................................110
Limitations and Deficiencies...................................................................................110
Not Founded Style from Global Style Template ........................................................111
Security 159
APplus Access Rights .....................................................................................................159
Report Permission Configuration ............................................................................160
JasperServer Access Rights ............................................................................................161
Features .............................................................................................................161
Setup and Configuration........................................................................................162
How It Works.......................................................................................................163
Index 189
JasperSoft Products
JasperSoft Capabilities
Fundamentals • Seamless embeddability using public Java APIs and Web services
• External authentication
• Role-based authorization
• Security
• Single Sign-On
• Internationalization
• Pixel-perfect output to printer, PDF, HTML, XLS, CSV, RTF, TXT, and
XML file formats
• Shared repository
• Scheduling
• Compliance snapshots
JasperReports
http://www.jasperforge.org
http://www.jasperforge.org
Quick Facts • Provides intuitive web-based ad hoc reporting for business users.
http://www.jasperforge.org
Operating Systems Linux and Microsoft Windows IBM AIX, Sun Solaris, Red Hat
Enterprise Linux (RHEL), Novell
SUSE Linux, Fedora Enterprise
Linux, Mac OS X, Debian Linux,
HP-UX, rPath Linux, Microsoft
Windows
JasperReports Architecture
Servers
Where
• the web server is responsible for interaction with the users and the
data presentation.
Note The JasperServer is able to use different application servers and is able
to use different database servers to host its repository.
<JasperServer>\docs\JasperServer-Pro-Install-Guide.pdf
iReport Plugin
(APReportExtensions- APReportExtensionsPlugin is a bundle of APplus plugins for iReport. It is
Plugin) deployed to iReport. The bundle includes:
Report Scriptlets
(APReportsScriptlets) Jasper Report Scriptlets
net.sf.jasperreports.engine.JRAbstractScriptlet
This class exposes all abstract methods to handle the events that occur
during report generation and provides data structures to access all
variables, fields, and parameters present in the report.
APReportsScriptlets
APReportsScriptlets is a jar file that bundles java classes that are used
during report rendering. There are two types of classes:
There
Run Time
Preview Operation
Server Interaction
4., 5. The database connection parameters are obtained from the application
server. The application server expands the SQL query from the report
to a fully qualified SQL query.
6., 7. A connection to the SQL server is created and the SQL query is
executed on the database server
Operation Flow
4. The JasperServer gets the report from the repository and selects the
appropriate query executer based on the query language used in the
report.
• executes the fully qualified SQL query on the database server and
returns the result to the rendering engine.
Print Operation
Server Interaction
2. On the web server the print request is created and added to the job
queue.
3. The print server checks the table JOB for print jobs.
1. The print server gets the print job from the table JOB.
2. The print server processes the job and creates a report rendering
request on the JasperServer (web service, runReport() method)
5., 6. The database connection parameters are obtained from the application
server. The application server expands the SQL query from the report
to a fully qualified SQL query
7., 8. The connection to the SQL server is created, the SQL query is executed
on the database server.
9. The rendered report is returned to the print server in the .jrprint format
11. The print server exports the report (to PDF) and stores it to the
document management system (DMS).
Operation Flow
2. The selection of the user and the internal parameters are collected.
5. The print server gets the print job from the table JOB.
6. The print server processes the job and creates the report rendering
request on the JasperServer (web service, runReport() method).
7. The JasperServer gets the report from the repository and selects the
appropriate query executer based on the query language used in the
report.
8. APplus uses the proprietary query language - apqe. In this case the
APQueryExecuter is selected. APQueryExecuter
• executes the fully qualified SQL query on the database server and
returns result to the rendering engine.
12. The print server exports the report (to PDF) and stores it to the
document management system (DMS).
Design Time
The JasperServer is not used to store and render reports. The jasper
rendering engine is part of iReport. The reports are stored in the
repository on the local file system.
1., 2. The report is selected and opened from the local file system.
3., 4. The database connection parameters are obtained from the application
server, the application server expands the SQL query from the report to
the fully qualified SQL query.
5., 6. The connection to the SQL server is created. The SQL query is executed
on the database server.
1. The report is selected from the local file system and opened in iReport.
• executes the fully qualified SQL query on the database server and
returns the result to the rendering engine.
8. Depending on the user selection in iReport for the report format, the
report is exported to the selected format (PDF, RTF, XLS, HTML, etc.).
• These source files are compiled to create a JASPER file (with the
.jasper extension), which is a kind of predefined report. The main
difference between using XML and a .jasper file is that the XML file
should be compiled at runtime using the JasperCompileManager
class.
Statistical Reports
Report Name
Naming Convention The Report name for statistical report is generated. We need to follow
the same rules (naming convention) as in the code when we name a
master report. The name is based on
• obtains the table name from the name of the page used for
statistical analysis.
Examples • auftragKurz
• abcAnalyseAV
• lagerbelegung
Report Design
SelParts.xml
• fields and join nodes are optional. We define them when the
grouping require modifications of the SQL query.
comment example
comment example
comment example
,GRUPPE=bmk.artikel, GRUPPENNAME=ARTIKEL.NAME, GRUPPE2=
</fields>
</group>
</analysis>
<analysis name="bewegung">
<group name="artikel">
<join>
</join>
<fields>
,GRUPPE=bmk.artikel, GRUPPENNAME=ARTIKEL.NAME, GRUPPE2=
</fields>
</group>
<group name="bmk">
<join>
</join>
<fields>
,GRUPPE=T3.SERIENNR, GRUPPENNAME=, GRUPPE2=''
</fields>
</group>
</analysis>
</table">
we have to
Analysis Type / The _auswertung and selobj values for other cases are presented in
Grouping Matrix Analysis type/Grouping matrix.
analysis type
Yes No
multiple Yes _auswertung = analysis type, _auswertung = grouping,
groupings
selobj = grouping selobj = grouping
No _auswertung = analysis type, _auswertung = ,
selobj = not defined selobj = not defined
we have to:
Analysis Type / The _auswertung and selobj values for other cases are presented in
Grouping Matrix Analysis type/Grouping matrix.
analysis type
Yes No
multiple Yes _auswertung = analysis type, _auswertung =,
grouping
selobj = grouping selobj = grouping
No _auswertung = analysis type, _auswertung =,
selobj = not defined selobj = not defined
How to …
Notes The report name for the (master) statistic report is generated. The
name is predefined!
The table name must be written in lowercases, the analysis type must
start with a capital letter.
• subreport: table[Analysis][subreport_name]_sub.jrxml
Report Name
Selection Process
1. Get the table name from the name of the Sel.aspx page, i.e.
nameSel.aspx -> name.
• The name attribute of the table node must be the name of the
Sel.aspx page.
<table name="table">
<analysis>
<group />
</analysis>
</table>
• The values of the name attribute are obtained from the Sel.aspx
page.
• We can get them from the URL (if we press the Auswahl als URL
button).
• selected elements with names ending with "_" are added to URL as
distinct report parameters (getExtendedReportParam(), selUtils.js),
• all parameters that are part of the URL are passed to the report.
Report Name
Report names are freely definable. They have to follow the naming con-
vention, though. The report name is defined in the DocTypes.xml file.
Report Designs
• list – master data list, e.g. company list, person list, etc. and
WebObjects\jobUtils.js, selectPrint()
function.
DocTypes.xml
Tag Description
<jobUserParam> Used to define the user parameters that are passed from APplus to
JasperServer. The @name attribute defines the parameter name.
The parameter value is nodes inner text.
How to ...
Standard Serial Serial printing for a document is configured in the DocTypes.xml file.
Printing Usually nothing else needs to be done.
WebObjects\jobUtils.js, printSerieStep()
external="true"
massJob="false"
Example:
<jobType id="lsexternserie (JR PDF)" PrintDialog="false"
title="Serie Lieferschein (PDF)" external="true"
massJob="false">
The customizations are usually implemented in several places:
• If processing succeeds, the print job is created in the job table (on
the application server).
• in the DocTypes.xml define the jobType node and set the external
attribute set to true.
• WarenausgangRec.aspx
The user has a possibility to select to print a report with or without total
sum.
• The report Auftrag with total sum is already registered in the
DocTypes.xml file.
When the user selects Auftrag (w/o total sum) from the print/preview
menu
• the total sum is not printed when the parameter exists and its value
is no.
Deployment
For detailed information about the deployment and integration steps for
the production system see Technische Beschreibung Jasper Reports
installieren und administrieren and Chapter "Deployment".
Integration
In the following section you find the explanation of the steps performed
by the APplus Manager during the integration.
JasperServer
../jasperserver-pro/WEB-INF/lib folder
.../jasperserver-pro/WEB-INF/classes
../jasperserver-pro/WEB-INF
com.apag.p2plus.p2reports.CustomReportService
com.apag.p2plus.p2reports.CustomReportService
5. Copy selection XML from the APplus web server (sel.xml, SelParts.xml)
../jasperserver-pro/WEB-INF/classes
7. Copy the PDF font map and the arial fonts (fontmap.xml (see section
"APplus Specific Components and Extensions" on p. 16), ari*.ttf) -
copies the default font map and fonts to the folder
../jasperserver-pro/WEB-INF/classes
The map is used when JasperServer exports reports with MARKUP texts
to PDF (see section "Markup Attributes" on p. 118).
iReport
../iReport/lib
3. Copy the selection XML from the APplus web server (sel.xml,
SelParts.xml):
../iReport/classes
.../iReport/lib
../iReport/classes
The map is used when iReport exports reports with MARKUP texts to
PDF (see section "Markup Attributes" on p. 118).
Configuration Files
Note: The configuration files are managed and deployed by the APplus
Manager.
2. Open the reporting plugin and then the tab Jasper Integration.
Here the configuration files, which are managed and deployed by the
APplus Manager, are listed here as a quick reference and checklist.
JasperServer
iReport
Module Module Reporting When this checkbox is set, the by default the
Services Reporting Services entry will be Reporting Services
statistik report available in the statistics menu. statistik report is
Note that Reporting Services enabled
fuer SQL has to be set as well
(Reporting Services module has
to be activated).
With this checkbox we have a
possibility to control the support
for Reporting Services based on
statistical reports independently
from Reporting Services support
for business related reports
(documents). When the Repor-
ting Services module is active,
we can disable the generation of
statistical reports with Reporting
Services (the Reporting Services
entry won’t be displayed in the
menu) by removing the check
from checkbox.
Report- General Setting of Enables user selection when the default value:
ing "Printing" "Gedruckt" flag will be set. The before printing
checkbox possible options are:
• before printing
• after printing
Report- JasperServer Save preview Allows to select document store- Default value:
ing in DMS age behavior during preview. checked
When the checkbox is set, the
documents will be stored to DMS
also during preview.
Report- Print Server The first The first instance of the print The print server
ing instance server defined in the configu- supports several
ration file. instances, each of
which works with
its own web server.
The instances are
specified in a con-
figuration file. Each
instance has a uni-
que name. The
print server instant-
ces can each be set
up for specific en-
vironments or
users. More infor-
mation is available
in the Print Server
documentation (see
"Mandatory
Configuration
Settings" on page
125).
Report- Print Server Users of the Users (separated with ";") who
ing first instance use the print server. All print
jobs that have been created by
these users are processed by
"Instance 1" (the unique name
of the print server instance).
Introduction
1. Open in the APplus Manager the module Reporting and then the tab
Jasper Integration.
Server Information The AppServer Adresse is used to populate the appserver parameter
when Report Run is used to execute the report.
http://host_name:port
e.g.
http://localhost:2037
Report Parameter • WebServer Adresse used to populate web server parameter. The
parameter contains the URL of the web server in the format
http://host_name/web_name
Repository Local report directory contains the path to the local report repository.
• shared subreports
• scriptlet library
Modules
• toolbar
• pane
Mandatory Way to The Report Run is a mandatory way to execute APplus reports.
Execute APplus
Reports
• The report name must follow the naming convention! The helper
obtains the table and analysis information from report name
(needed to get the selFields and selJoin parameter from the file
selParts.xml).
selParts_<company>.xml
Authoring
When the report is joined with the data generating the print, these
sections are printed as many times according to their function and
according to the rules that the report author has set up. For instance:
Notes • A band is always as wide as the page width (right and left margins
excluded).
This typically occurs when bands contain subreports or text fields that
have to adapt to the content vertically.
• The sum of all band heights (except for the background) has to
always be less than or equal to the page height minus the top and
bottom margins.
Reference A description of each of the predefined bands plus the bands for groups
can be found in the documentation The Definitive Guide to iReport™ in
Chapter 3 page 26.
Fonts
Styles
• Report Scriptlets
• Utility classes
Subreports
JasperReports Built-in JasperReports provides some built-in parameters (they are internal to
Parameters the reporting engine) that are readable but not modifiable by the user.
• The report specific subreports are located in the same folder as the
master report and are referenced with their name with the exten-
sion jasper.
• The shared subreports are located in the folder shared and are
referenced with the help of a relative path in their name.
$P{REPORT_PARAMETERS_MAP}
$P{REPORT_CONNECTION}
Reusing Connection We have to pass the report connection to each subreport that obtains
data from the database.
Compiling Subreports
Tables
Despite the lack of table elements we can simplify our work with tables
(to certain extent) by
Tables are typically composed with a table header, detail section and
table footer. In Jasper Reporting we can design a table by assigning
table elements to report bands. The common approach is to use column
or group bands as a table header and a footer.
Example • angebotAngebotUst_sub.jrxml
Example • bestellungBestellunPos_sub
We use the frame element to group elements with the same properties
(e.g. table row cells). We can set properties to a frame instead to each
element separately. The same is valid also for elements expressions.
Some examples of usage are:
• using a style.
• The Remove line when blank property defines that the line should
be removed when it is not printed.
Report Parameters
Parameters are values that are usually passed to the report from the
program that creates the print of the report. They can be used for
guiding particular behaviors during runtime (such as the application of a
condition in a SQL query) and for supplying additional data to the print
context such as the path to the images stored on the web server.
WHERE bestellung=$P{docNr}
• All parameters added to the requested URL are passed to the report
engine.
• custom parameters are defined by the user and can influence the
report rendering or be used in the report design.
$P!{paramName} Syntax
For example, if you have a parameter named MyWhere with the value
of where CUSTOMERID = 5, the query
select * from customers $P!{MyWhere}
• appserver,
• p2user and
• env.
• is used by APQE to
• preprocess the SQL query and create the fully qualified SQL
query.
• contains the APplus internal user name (as defined in the table
PERSONAL).
Note: In this case the internal user name is NOT used directly.
It is converted to the windows user name prior to perform web
service calls.
Mapping of the You configure the user mapping of the windows user to the APplus user
Windows user to the in the APplus Manager with the order AppServer > User-Mapping.
APplus user
The mapping defines the content of the parameter p2user. We can
select between Active Directory and user mapping of the domain.
When UserMapping is
none n/a Windows user in The windows user name and the
form: APplus user name must be
domain/username equal.
servername The name of the server hosting the web (e.g. all
virtualpc)
noclient statistics
where=ARTIKELGRUPPE%3D[1000;]%26DATUM%3D[2003-10-
05T00%253A00%253A00;2009-10-
05T23%253A59%253A59]%26WAEHRUNG%3DEUR
DATUM=[2003-10-05T00%3A00%3A00;2009-10-
05T23%3A59%3A59]
WAEHRUNG=EUR
The elements (fields, checkbox, etc.) on a Sel page are basically divided
in two categories:
• one that have names equal to field names of tables in the database.
• one that are not named as field names of tables in the database.
• the elements with names ending with "_" are added to the URL also
as distinct report parameters (getExtendedReportParam(),
selUtils.js),
• all parameters that are part of URL are passed to the report,
APQE APQE has a special handling for the parameter WHERE (collection of
key=value pairs):
• it removes all keys that start or end with "_", the exception is
_BDATUM,
• it assumes that other keys are valid field names in the database
and creates a search criteria in SQL syntax,
Passing search or Passing search or filtering criteria at run time (for non statistical re-
filtering criteria ports):
Solutions Solution A:
• Solution B:
Purpose The purpose used by statistical reports is to define and pass selected
sort order by the user.
• it removes the ORDER BY sentence (from the SQL query) when the
parameter orderby is not defined (and is the only sort criteria, i.e.
ORDER BY $P{orderby})
Parameters selGroup, • The parameters selGroup, selFields, selJoin are used in statistical
selFields, selJoin reports.
• They provide the grouping and grouping specific SQL query snippets
from the webserver.
• The values for the selFields and selJoin parameters are obtained
from SelParts.xml (see section "SelParts.xml" on p. 27).
The custom parameters are defined by the user and can influence the
rendering of the report or can be displayed in the report. The user
usually has to
• make sure that the parameter is passed to the print or preview URL
request.
• the folder documents contains all documents, i.e. doc, out and
master data reports.
• The folder shared contains the resources, that are shared between
reports, e.g. subreports, resource bundle, style and scriptlets.
modul1
|--documents
| |--reportname01
| |--reportname02
| |--reportname02_sub
| |--reportname02Subname_sub
| |--subname_sub
|
|--statistics
| |--reportname01
|
modul2
|
Shared
|--subreports
• Name of the modul: name and label = beginning with a lower case
letter (e.g. "automotive").
Report structure Master report is separated from its Report units are used to represent
resources. The resources are reports in the server. The report unit
spread in the repository depending is a container that contains the
on their type (resource bundle, master report, input controls and
image, subreport, etc.) and usage resources. Input controls folder
(local, shared). contains controls needed to enter
report parameters (via web
interface). The resources folder
contains local subreports and explicit
resource reference links.
Report compiling The master report and all its The master report and all its
subreports (local and shared) subreports are compiled by the
must be compiled prior to the re- server on the fly when the report is
port execution. Only the master executed (run).
report is compiled during report
execution (run).
Naming Convention
• WITHOUT name of the module und WITHOUT typ (List, Out or Doc).
The affiliation to the module and to the type will be figured through
the hierarchy of the folders, e.g. bestellungBestellung.jrxml.
Subreport • Subreports and master reports are subject of the same naming con-
vention, but plus topic plus "_sub" or
The name of a table is necessary, because there exists reports with the
same name, which are stored in the same directory but refer to differ-
ent tables, e.g. "Mahnung".
Statistical Analysis
Examples
before after
purchaseBestellungArtikelgruppeKurzList bestellungKurz
AplanOut aplanArbeitsplan
PeriodAbschlOut personalPeriodAbschl
Name Of the Name of the document subreport: = name of the parent report +
Document "_sub"
or
Example • personalPeriodAbschlDetail_sub,
• lieferabrufinLieferliste_sub,
• wauftragKopf_sub
Report Types
• list – master data list, e.g. company list, person list, etc.
• report integration
In the folder
/reports/<Company>/shared/templates
you find several templates you can use as a starting point to build new
reports (and subreports):
• ApplusReportTemplateBasic
• ApplusReportTemplateStandardDoc
• ApplusReportTemplateStandardList
• ApplusReportTemplateTablenameKurzDetail
• we make all the static text set at design time (such as labels and
messages) adaptable to locale options used to build the report.
Usage of Locales Locales are used throughout the reports to customize how data is
presented and formatted. They affect language choice, collation,
calendar usage, date and time formats, number and currency formats,
and many other culturally sensitive data representations.
• How is the locale report set in APplus (for detailed information see
"… in APplus" on p. 91)?
• How is the locale report set in iReport (for detailed information see
"… in iReport" on p. 93)?
Currency Each locale has its own preferences for currency symbols, negative
amount format, leading zeros, group separators, decimal point symbol,
and currency symbol position.
Date and Time Like other locale-sensitive structures, dates have many representation
details. We must consider long and short date formats as well as date
separator symbols. We have to worry about whether the year is
displayed before the day and month or after.
Localizing a report means making all static text set at design time (such
as labels and messages) adaptable to locale options used to build the
report. The report engine will print the text using the most appropriate
available translation. The text translations in the different languages
supported by the report are stored in particular resource files
collectively named the Resource Bundle.
Resource Bundle
Caveat You'll need to understand following caveat regarding resource bundles:
\uXXXX
where
XXXX
Note: JDK provides the native2ascii tool that converts a file written in
native encoding to one that represents non-ASCII characters as Unicode
escape sequences.
Limitations of Native
Localization Support iReport supports report localization. In order to use this functionality
in iReport the following requirements must be met:
• Resource bundle files must have the same name as the report files
(except for file extension).
• The resource files are spread across the repository, which is difficult
to maintain.
• The same text can be spread in multiple files, the corrections has to
be done in multiple files.
Benefits • One resource bundle that contains texts from all reports. The
Translator gets one resource file instead of many.
ApplusJReports/shared/bundles
Requirements We need to use custom tools in order to create and use localized
reports (in iReport, JasperServer and APplus). We have to make sure
that the following requirements are met:
Additional Information
Report Design
2. Use the Localizer tool to convert static texts and update the resource
bundle file.
Verify Report
• date,
• time,
• numbers and
• currency.
• by using the Pattern editor for this purpose you had to click on the
Create… button, where you can select a pattern from predefined
ones.
Date To determine the standard formatting of date fields you had to write in
the Pattern dropdown list manually
short,hide
Numbers To determine the standard formatting of number fields you can select
the predefined pattern
#,##0.00;-#,##0.00
Custom Formatting
DateFormat []
http://java.sun.com/j2se/1.4.2/docs/api/java/text/DateFormat.html
http://java.sun.com/j2se/1.4.2/docs/api/java/text/NumberFormat.html
Required Text Field If you want to change the properties of a text field, you had to do the
Properties following:
1. Open the dialog to change the element properties of a text field and
than open the Text Field tab.
4. To the field Text Field Expression enter the appropriate java class
depending on the data you are formatting (see examples bellow).
getDateInstance()
getTimeInstance()
getNumberInstance()
getIntegerInstance()
getPercentInstance()
getCurrencyInstance()
… in APplus
REPORT_LOCALE
Parameter
Report Type
Statistical Analysis Other (Doc, List,
Out)
Operation Print language preferences print dialog
Type
for the browser
Preview language preferences table, SPRACHE
for the browser
PREVIEW For the operation to preview a document it is not possible to select the
document language.
PRINT For the print operation we can define, that the user is prompted to
select a language for the printed document.
WebObjects\DocTypes.xml
2. Edit or create a jobType node that defines the print job for the docu-
ment.
The resource bundles for all supported languages must exist and have
to contain translated texts from the report (and its subreports) in order
to get the translated version of the report.
Statistical Reports
Print and Preview Reports for statistical analysis are based on views.
… in iReport
During the design phase we might need to change the locale to check
how locale dependent data are rendered.
1. You can change the locale in iReport with the command Build > Set
Report Locale.
… in JasperServer
1. In the Login prompt select the link Show locale & timezone
Resource bundle files have to be edited and managed with a editor that
performs automatic native2ascii conversion. The public available tools
are
• NetBeans,
• PrbEditor and
To create and edit language resource bundle files you are using the
Übersetzung plug-in of the APplus Manager.
4. Enter in the field Sprachkürzel the ISO Code of the language, e. g. en,
en_US, ….
3. Select in the column of the desired language and edit in the row
containing the text you want to translate.
We use the Localizer and Mass Localizer to convert report texts to the
references.
ApplusJReports/shared
We use the APplus Manager to deploy reports and resource bundles files
to the JasperServer.
1. Open in the APplus Manager the plugin Reporting and the tab
Repository.
1. Open in the APplus Manager the plugin Reporting and the tab
Repository.
5. To run a report, click on the button View and select the option
Repository.
6. Open the folder Reports and then the folders <CompanyName> with
your company name and <module> documents.
10. To change again the locale setting on the welcome page of the
JasperServer click on the button Show locale & time zone and change
the selected language, i.e. to German.
1. You must edit or create a jobType node that defines the print job for
the document.
3. Add the node jobDotFile for each language that has to be supported.
4. Set the value of the language attribute. The value must correspond to
the language code
The resource bundles for all supported languages must exist and have
to contain translated texts from the report (and its subreports) in order
to get the translated version of the report.
1. Open APplus and open the page Edit order in APway with the command
purchase > order > edit order and select an order.
2. To print the order, you had to click in the toolbar on the button Print
and then select Bestellung (PDF).
The document is rendered in the language you had choosen in the print
dialog.
1. Open the tab Info tab on a Rec-Page, where you can preview a
document, and show which language is selected in the dropdown menu
Sprache.
1. To print the order, you had to click in the toolbar on the button Print
and then select Bestellung (PDF).
Styles
What Is a Report A report style is a collection of style settings declared at the report
Style? level. These settings can be reused throughout the entire report
template when setting the style properties of report elements.
Example Each text element present on the report can have its own font settings.
Since a report usually uses only a few types of fonts shared by different
text elements, there’s no point to specify the same font settings re-
peatedly for each text element. Instead we reference a font declaration
in a style and adjust only some of the font settings on the spot, if a
particular text element requires it.
2. In the dialog Styles press the New button to add a new style.
This opens a Style definition dialog where we can define a new style.
Style Name The field Style name is the only mandatory field in the dialog
Add/modify style. All other fields are optional.
Default Report Style The Default style field defines a style to be the default style of a report.
If a default style is present, all the element properties that have an
unspecified value will implicitly inherit a value from the default style.
Cascading Report The Parent style field specifies the name of the parent report style.
Styles Each report style definition can reference another style definition from
which it will inherit some or all of its properties.
Conditional Styles
Instead of "normal" styles you can also use in Jasper Reports so called
conditional styles. Conditional styles are styles, which are used when a
field has a special value or when a particular position in a subreport is
achieved.
Meanwhile it´s impossible to implement conditional styles as global
styles, so therefore you had to realize a conditional style manually.
1. Open the docking pane Styles Library with the command View >
Docking panes > Styles
2. Select in the dropdown menu Report Styles.
3. Move the cursor in the window of the docking pane and use right
mouseclick and select the option New Style.
iReport opens the Add/modify style dialog.
4. Click on the button Add. Then you must add a new condition to the
style.
5. Define the expression, which should apply for this style and click the
button Apply.
If the expression is true, the defined style is used instead of the default
style.
In the next figure you can see, that the value is represented in red, if
the value is 0.
Reusing Styles
Defining Styles Instead of repeatedly defining similar styles for each report, we define a
style in the Styles library and reuse it in other reports. To use a style
from the library, we drag a style from the library over an element. If
the style is not yet present in the report, it is copied to the report from
the library (added as a report style), and the Style attribute of the
element is set to the name of the selected style.
Note: The deficiency of this approach is once a library style has been
applied to a report, any later changes to that library style will not be
updated in the report style. To overcome this issue we use styles
defined in the Style Template file.
The style templates provides support for reusable report styles. Styles
are stored in separate files, so called Style templates. The templates
have .jrtx extension. The Template file can include another template
file.
The styles defined in the template are shared between all reports that
use the template. We have a central place where styles are defined and
managed. The changed style in the Style temple is visible in all reports
that use the template.
Creating the Style Creating a Style template and adding a style to it is easy.
Template
2. Switch in the docking pane Styles Library to the Styles library view.
3. Move the mousecursor on the pane and use a right click and select the
option New Jasper Template.
1. Right click on the folder and select the option Add Style to Jasper
Template.
2. Create a style.
The only mandatory parameter is Style name.
1. You can use a style with drag and drop the style from the Styles library
view to the static Text (or Text fields) in the report.
On the Common tab on the properties dialog of the element you can
see the style in the dropdown menu Style used by the element.
Notes When a style is applied to the report element, the style and template
references are added to report.
APplusStyles Template
All APplus reports must use the Style template. The template is stored
in the shared part of the repository
"…/ApplusJReports/shared/styles/ApplusStyles.jrtx"
Which styles are defined in the Style template and how they are used in
the reports is described in Technische Beschreibung Jasper Reports
installieren und administrieren and Chapter "Jasper Reports Styles". The
topic also describe how to use the Style template in iReport.
Effect The used style is being shown greyed out and with warning sign under
"Report styles"
When running the report, the style is being found and works.
Introduction The default format for documents (reports) generated by APplus is PDF.
To obtain the desired output as PDF we need to understand how Jasper
Reports used the font properties and how the rendering engine of
Jasper uses the fonts.
This chapter also describes the encountered issues when generating
PDF documents and how they were solved.
Font Properties
• PDF Font Name: The name of the font (it could be a predefined PDF
font or the name of a TrueType font (TTF) file present in the
classpath (see below).
If the report is not exported to the PDF format, the font used is the one
specified by Font Name and is enriched with the specified attributes. In
the case of a PDF document, PDF Font Name identifies the font used
and its attributes (bold, italics, etc.). For example
arialbd.ttf
defines the Arial font and bold attribute. Other attributes are ignored
since they are inherited from the specified PDF font.
Usage of external You can use external True Type font(s). To do so, the external fonts,
TrueType fonts these are files with .ttf extensions, must appear in the classpath. This is
necessary
Fonts inherited by the The Font name combo box in the Font tab of the element properties
operation system dialog, shows only the system fonts, managed by the Java Virtual
Machine (JVM).
These are usually inherited by the operating system. Therefore, to
select an external TTF font to use in non-PDF reports, you had to install
the font on your system before you can use the font.
The PDF font name combo box displays a list of PDF built-in fonts and
all TTF files found in the classpath on startup. These fonts are used
when the report is exported to PDF format. Therefore, to select an
external TTF font to use in PDF reports, we have to deploy it to
directory in classpath.
Notes • Scanning the whole classpath to look for TTF files is really
timeconsuming in terms of startup time. For these reasons, iReport
provides a possibility to limit the number of directories to scan
when looking for fonts.
To define the fonts path select in iReport Options > Fonts path and
check all the directories and JARs that must be scanned when
looking for fonts.
Unicode Notes • Unicode fonts are typefaces containing a wide range of characters,
letters, digits, glyphs, symbols, ideograms, logograms, etc., which
are collectively mapped into the standard Universal Character Set.
• The Font Path of iReport must point to a location where the fonts
were deployed.
• PDF Font Name defines the font file that will be used when the
report is exported to PDF.
Note: In the field PDF Font Name is a file selected that contains a font
with certain attribute applied. Example mappings:
Using Unicode Font in In the standard implementation all Static Text elements and Text Field
The Style Template elements (in reports) has to use a style from the APplusStyles template.
The template uses Unicode font. The default style defines an Arial font
together with other mandatory properties for Unicode support:
All styles are derived from the default style. If a style uses formatting
attributes (Bold, Italics, Bold Italics) it updates the specified style in the
field PDF Font Name appropriately, i.e. when the Bold attribute is set in
the style, the specified font in the field PDF Font Name for the style is
changed to
arialbd.ttf
The same approach must be used also for other Unicode fonts that are
added to the style template.
Text formatting
Styles Used by Static Normally, all the text content in a text element has the style specified
Text and Text Field by the text element attributes (text foreground color, text background
color, font name, font size, etc.). But in some cases, we want to
highlight a few words inside a text element, e.g. changing the font color
or style (bold or italic) or layout the text (by using a list). In such cases
the text content of that particular text element will no longer be pure
text, but it will include formatting information in the text itself.
Static Text …
…is changed to
Result • bold
• italics
• underline
superscript
•
• subscript
Markup Attributes
The Markup attribute on the Font tab of the element properties dialog
provides support for RTF and HTML snippets inside of text elements.
The APplus reports use markup attribute since 50F04. The attribute is
used when fields contain HTML formatted text. Some tables in APplus
have fields that contain HTML snippets (e.g. offer or order). The
snippets are created with the FCKeditor. The JasperReport engine
supports only a limited number of HTML tags:
• <B>, bold
• <I>, italics
• <U>, underline
• <SUP>, superscript
• <SUB>, subscript
• <STRIKE>, strikethrough
• <LI>
• <BR>
Notes • The unsupported tags are ignored (filtered out) by the engine.
• The engine supports <B> and <I> tags, but not <STRONG> and
<EM>, which are generated by the FCKeditor.
• There is an issue with <LI> tag (for more details see section
"Markup <LI> issue" on p. 122)
filterHTML() scriptlet The filterHTML() scriptlet function has to be used to preprocess the
HTML snippets. The function
• replaces the tag <STRONG> with <B> and the tag <EM> with <I>.
If you want to use the function, you have to enter the following line in
the Text Field Expression:
new
com.apag.p2plus.p2reports.scriptlets.APScriptlets().filterHT
ML($F{ARTIKELTEXT})
where $F{ARTIKELTEXT} is the field containing the HTML snippet.
The Is styled text attribute indicates, whether the text content of the
element is pure text or has embedded style information. All text
elements have this special flag.
When the report contains HTML formatted text (uses MARKUP font
attribute) and is exported to PDF, the bold and italics attributes are not
applied to the text. This issue is present in iReport, on the
JaspserServer and the APplus web server.
To overcome the problem a PDF export extension was developed. You
can read more about the extension in chapter "Custom PDF exporter"
on p. 155.
PDF Export of Styled Text Doesn't Work When Using Web Service
We use the "PDF export extension"’ to overcome the PDF export issue
(see below) of inline formatted texts (see section "Text formatting" on
p. 117). The solution works when reports are exported to PDF on
JasperServer and in iReport.
But it doesn't work, when reports are previewed from APplus. When
APplus sends a report Run request via web service where PDF is set as
export format the report is not exported correctly. Export to other
formats such as RTF, HTML, jrprint (and also to PDF that doesn't
contain formatted texts) works correctly.
The issue was fixed by JasperSoft. The fix was provided as a patch for
the JasperServer v3.1. The fix was deployed as part of the 50F04 fix
pack.
Problem with the FCKeditor is used to produce the HTML formatted texts. In the reports
<li> tag these texts are rendered with the Markup attribute set to HTML
(markup="HTML"). When the <LI > tag is present in the text, the
report rendering fails with the following exception:
Error filling print… Invalid substring range
java.lang.IllegalArgumentException: Invalid substring range
at java.text.AttributedString.addAttributes(Unknown Source)
at
net.sf.jasperreports.engine.util.JRStyledText.getAttributedString(JRStyledText.java:1
13)
at
net.sf.jasperreports.engine.util.JRStyledTextParser.write(JRStyledTextParser.java:223
)
at
net.sf.jasperreports.engine.util.JeditorPaneHtmlMarkupProcessor.convert(JeditorPaneHt
mlMarkupProcessor.java:157)
at
net.sf.jasperreports.engine.fill.JRFillTextElement.processMarkupText(JRFillTextElemen
t.java:1356)
at net.sf.jasperreports.engine.fill.JRFillStaticText.(JRFillStaticText.java:57)
at
net.sf.jasperreports.engine.fill.JRFillObjectFactory.visitStaticText(JRFillObjectFact
ory.java:658)
at net.sf.jasperreports.engine.base.JRBaseStaticText.visit(JRBaseStaticText.java:101)
at
net.sf.jasperreports.engine.JRAbstractObjectFactory.getVisitResult(JRAbstractObjectFa
ctory.java:91)
at net.sf.jasperreports.engine.fill.JRFillElementGroup.(JRFillElementGroup.java:86)
at
net.sf.jasperreports.engine.fill.JRFillElementContainer.(JRFillElementContainer.java:
91)
at net.sf.jasperreports.engine.fill.JRFillBand.(JRFillBand.java:87)
at
net.sf.jasperreports.engine.fill.JRFillObjectFactory.getBand(JRFillObjectFactory.java
:518)
at net.sf.jasperreports.engine.fill.JRBaseFiller.(JRBaseFiller.java:451)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.(JRVerticalFiller.java:77)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.(JRVerticalFiller.java:59)
at net.sf.jasperreports.engine.fill.JRFiller.createFiller(JRFiller.java:147)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:57)
at
net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:402)
at
net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:234)
at it.businesslogic.ireport.IreportCompiler.run(IreportCompiler.java:947)
at java.lang.Thread.run(Unknown Source)
Workaround JasperSoft is preparing the fix for the issue. Meanwhile we are using the
workaround proposed by Jasper support, adding after each
<LI> tag. The workaround is implemented in the filterHTML() scriptlet
function. :
Overview
• pools the APplus web server for print jobs and process them.
When a new print job is created in APplus, the print server obtains that
job, contacts the JasperServer for rendering the report and prints the
rendered report on one of the configured printers.
• one instance can process print jobs from one web server,
• supports logging.
• can use different sizes of paper, so that the size of the report forces
the size of the paper, so that you can print labels for example (since
50F07).
In the print dialog all printers are displayed, which are known by all
printer servers. This will be considered, whether a print server uses
only certain environments or certain users.
As soon as the print server runs, the print server submits to APplus
always the printers, which the print server knows, in the demand
for printing jobs to be performed by whatever printer. This infor-
mation is stored in the new table DRUCKER.
When the client opens the print dialog, then APplus displays the
correct printer based on the configuration of the print server in the
system configuration. The printer default printer and e-mail
(documents deposited with the e-mail address) will always be
displayed.
When you restart the application server, the information in the table
DRUCKER is adjusted so that the information is to be deleted from
the print servers that are not configured in the system configu-
ration.
This has the consequenz that users can now print on their locally
attached printer via the print server. To do this, this printer must be
shared on the client and the share on the print server must be set
up.
• APplus
• JasperServer
Windows/fonts
Tools/APplusPrintService
Export the folder to any location on your local file system. The folder
will contain:
File Description
Before you can start using the print server, you have to perform the
configuration changes in the configuration files of the print server and
in the systemconfiguration of APplus.
Basic Configuration All JasperReport print jobs will be served by the configured print server
instance.
2. Select the company (Firma), for which you want to configure the print
server.
4. Enter in the field First Instance the instance name of the print server
you defined in the file printserver.config.xml (name attribute, see
below).
Extended
Configuration
Leave the field Environment for the first instance empty, when you
want that print jobs from all environments are printed on the selected
print server instance.
2. Define a user in the field User for the first instance when you want that
only print jobs created by specified user(s) are printed on the selected
print server instance.
Leave the field User for the first instance empty, when you want that
print jobs from all users are printed on the selected print server
instance.
3. The user names must be the APplus user names (p2user) (as defined in
PERSONAL table).
4. Be aware that environment and user definitions are joined together with
AND, when a job filter is created. So, if you specify an environment and
a user from a different environment, the print server will not get any
print job.
• install_service.cmd,
• uninstall_service.cmd and
• run_on_console.cmd.
Please note that after installing the APplusPrintService you still have to
configure and start the service with the relevant service user on the
services manager of the operating system.
Notes • The logging output must be set to FILE, when the print server is
running as a Windows service.
uninstall_service.cmd
Technical Description
Class Diagram and Technical details such as the class diagram and the sequence diagram
Sequence Diagram are described in the following passages.
The class diagram of the print server application shows all classes that
are implemented in the print server and their relationships and usages.
For better understanding the remote external components are also on
the diagram and are drawn in green color (webserver, jasperreports)
and classes from other libraries are colored in blue (Properties,
TimerTask, Thread, Win32Service).
As it can be seen on the diagram the print server can also be run by a
user on the console.
Javadoc Developers, who are interested in the API, can generate the
Documentation documentation from source code comments by using javadoc.
Basic Printing Flow Basic printing flow is described in the chapter "JasperReports
Architecture" (for details see section "Print Operation" on p. 20).
Notes
The print server doesn't render reports. Reports are rendered by the
JasperServer.
• exporting the report to PDF and sending the PDF to the web server
(to be stored in DMS).
The columns have to be placed or moved in the template using the API
before running the report.
APCustomJSReportService
removeColumns Only reports that have removeColumns parameter defined and properly
Parameter initialized are preprocessed. Two values can be defined for the
removeColumns parameter:
Report Processing Report processing is done in two steps. In the first step non visible
elements are removed and remaining elements are compacted. In the
second step the freed space is redistributed and is applied only if the
user selects to redistribute the freed space.
JasperServer Integration
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl
jasperserver-pro/WEB-INF/lib
iReport Integration
iReport/lib
The deployment has to be performed with the APplus Manager with the
command APplusManager > Reporting > Jasper Integration > iReport:
• The expression in the Print when expression used for column hiding
can contain only parameters (fields and variables are not
supported).
Limitations
• When the fields are not properly positioned, i.e. the fields couldn´t
be removed correctly if they don’t belong to the frame, and are
positioned between fields that belong to the frame columns.
• The number of columns must be equal in all rows in order for the
redistribution to work correctly. When this requirement is not
satisfied, the column alignment is wrong (lost).
Example
../purchase/statistic
• the same expression in the field Print when expression was applied
on all elements forming a column,
When the columns are removed, the empty row space is not recovered!
1. For each column combination create a separate table header row, table
detail row and a table footer row.
2. Conditionally display the proper table header, table detail, table footer
row.
../sales/statistic
Table Header
Table Detail
• (custom) SQL,
• Sel Info,
• Mandant,
• Web Service.
Query Executers Which of the query executer is selected based on the first word in the
query:
Tasks of apqe Besides the query execution apqe performs other tasks:
Execution Contexts apqe is bundled together with two other jar files to
APJasperExtensions.jar and deployed to iReport and the JasperServer.
• APplus - the run request of the report is sent from APplus. The
request is processed by the JasperServer. apqe runs on the
JasperServer.
The APSqlQueryExecuter is used for all queries that start with the
SELECT keyword. The AP SQL Query Executer is a subclass of the
JRJdbcQueryExecuter
and the query execution flow is basically the same as if normal SQL
language would be used in the report.
The differences lay in the manipulation of the SQL query before the
query is executed on the SQL server.
Execution Sequence
Usage APSelinfoQueryExecuter is used for all queries that start with the
SELINFO keyword.
The language parameter is used for field translation and for locale
dependent data formatting.
• string,
YYYY-MM-DDThh:mm:ss
hh:mm:ss
Sel_<company_name>.xml
Parameters • xmlnode - the node from which the label is read (from the file
Sel.xml)
Execution Sequence
The APMandantQueryExecuter is used for all queries that start with the
MANDANT keyword. It is provided for obtaining current mandant based
on environment parameter given in report.
Syntax mandant
Parameters • N/A
Execution Sequence
Function Parameter When parameters or variables are used as function parameters, they
are replaced with their values prior to the web service invocation!
The web service has to return some data in order for the field reader (in
iReport's query editor) to work and retrieve the fields.
Limitation The returned XML rowset is only partially converted to the DataSource.
The schema dtType attribute is just been ignored. The APWebservice-
QueryExecuter passes the name and the content of the field to the
DataSource. The data type is set to string regardless of the value of the
dtType attribute.
The user information is used to access web services and to obtain the
DB connection.
Has the functions to read the mandatory parameters from the config file
and is aware of the selected company.
APQueryExecuter- The reader of the fields uses the apqe factory to instantiate proper
FieldsProvider apqe.
Utility classes The classes P2WebUtils and P2QueryUtils were refactored in order to
support user specific web service consumption (application server,
p2user).
They use the factory of the web service to obtain SOAP stubs.
The factory stores the proxy for reuse and the key is:
The factory is used by web utils and scriptlets that need web services.
applus.config.xml
http://server:port
http://server/company_name
How To ...
JasperServer Add the following text to the file log4j.properties in the folder
C:\Program Files\jasperserver-pro-3.0\apache-tomcat\webapps\jasperserver-pro\WEB-
INF\log4j.properties:
### AP loggers
log4j.logger.com.apag=DEBUG
log4j.logger.com.apag.p2plus.p2reports=DEBUG
log4j.logger.net.sf.jasperreports.engine.query=DEBUG
The output is being written to i.e.
C:\Program Files\jasperserver-pro-3.0\apache-tomcat\webapps\jasperserver-pro\WEB-
INF\logs\jasperserver.log
iReport Create log4j.properties and add the following text to the file:
# Global logging configuration
# console output
log4j.rootLogger=ERROR, CONSOLE
# Console output...
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.conversionPattern=%d{ABSOLUTE} %5p %c{1},%t:%L - %m%n
### AP loggers
log4j.logger.com.apag=DEBUG
log4j.logger.com.apag.p2plus.p2reports=DEBUG
log4j.logger.net.sf.jasperreports.engine.query=DEBUG
Put the file in the folder
iReport/classes
D:\Java\iReport-3.0.0\iReport.log
JasperServer To debug apqe, you have to run Tomcat in debug mode and then attach
to Tomcat.
Without Service
-Xdebug -
Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
to JAVA_OPTS in:
\jasperserver-pro-3.0\apache-tomcat\bin\setenv.bat
With Service
C:\Program Files\jasperserver-pro-3.0\apache-tomcat\bin\tomcat5w.exe
2. Add under
Java/Java Options
iReport To debug apqe in iReport, you have to run iReport in debug mode and
then attach to iReport.
\bin\startup.bat
CLASSPATH=
\iReport.bat
... Jahresvergleich
Legacy Code
Note: The Jahresvergleich implementation in apqe is legacy code. The
implementation was ported from custom data provider for Reporting
Services.
where=_BDATUM%3D[2004-01-01T00%253A00%253A00;2004-
12-31T23%253A59%253A59]
Example RechnungVergleichSel.aspx
*Sel.aspx Page The *Sel.aspx page contains the input field Buchungsdatum.
The _BDATUM and _BDATUMX serve as a start or end marker for a SQL
snippet that has to be processed prior to the query execution, e.g.:
SELECT
VGL=t.artikel,
VGLNAME=vgl.name,
_BDATUM=" ,
ZEITRAUMUMSATZ=SUM(t.umsatz),
LFDGJUMSATZ=SUM(t.umsatz),
VORGJUMSATZ=SUM(t.umsatz),
VVORGJUMSATZ=SUM(t.umsatz),
LFDVJAHRUMSATZ=SUM(t.umsatz),
VJAHRVVJAHRUMSATZ=SUM(t.umsatz),
LFDGJDECKUNG=SUM(t.umsatz),
LFDGJMARGE=SUM(t.umsatz),
VORGJMARGE=SUM(t.umsatz),
ZEITRAUMMENGE=SUM(t.menge),
LFDGJMENGE=SUM(t.menge),
VORGJMENGE=SUM(t.menge),
VVORGJMENGE=SUM(t.menge),
_BDATUMX=" ,
GRUPPE=t.artikelgruppe,
GRUPPENAME=gj.name
FROM f_rechnung as t
left outer join artikelgruppe gj ON t.artikelgruppe =
gj.artikelgruppe
left outer join artikel vgl on t.artikel = vgl.artikel
WHERE $P{where}
GROUP BY t.artikel, vgl.name, t.artikelgruppe, gj.name
apqe apqe checks for the _BDATUM key in the where parameter.
JasperServer APplus Manager > Reporting > Jasper Integration > Jasper Server and
set the following checkboxes:
Manual Steps
The edited section should look like this (notice apqe language):
<entry
key="com.jaspersoft.jasperserver.api.metadata.jasperreports.
domain.JdbcReportDataSource">
<bean
class="com.jaspersoft.jasperserver.api.engine.jasperreports.
util.DataSourceServiceDefinition">
<property name="serviceBeanName"
value="jdbcDataSourceServiceFactory"/>
<property name="supportedQueryLanguages">
<set>
<value>sql</value>
<value>SQL</value>
<value>apqe</value>
<value>APQE</value>
</set>
</property>
</bean>
</entry>
iReport APplus Manager > Reporting > Jasper Integration > iReport and set the
checkbox
Manual Steps
3. Register the AP Query Executor in iReport with the command iReport >
Options > Query executors > New.
Field Value
Language apqe
Overview
In cases when the value of a displayed text field containing HTML tags
(specifically <B> and <I>), the text in the PDF output is not styled as
to be expected. The bold and italic tags are ignored. In order to fix this
problem, a font map needs to be set as a parameter for the PDF
Exporter.
The reason of this problem is that in PDF bold and italic assigned text
must use a different font (derived from the base font). The PDF
Exporter needs to find at run time the font mappings.
JasperServer Solution
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl
jasperserver-pro/WEB-INF/applicationContext.xml
../jasperserver-pro/WEB-INF/classes
<fontMap>
<fontKey pdfName="Arial" isBold="false" isItalic="false" >
<pdfFont pdfFontName="arial.ttf" pdfEncoding="Identity-H" isPdfEmbedded="true" />
</fontKey>
<fontKey pdfName="Arial" isBold="true" isItalic="false" >
<pdfFont pdfFontName="arialbd.ttf" pdfEncoding="Identity-H" isPdfEmbedded="true" />
</fontKey>
<fontKey pdfName="Arial" isBold="false" isItalic="true" >
<pdfFont pdfFontName="ariali.ttf" pdfEncoding="Identity-H" isPdfEmbedded="true" />
</fontKey>
<fontKey pdfName="Arial" isBold="true" isItalic="true" >
<pdfFont pdfFontName="arialbi.ttf" pdfEncoding="Identity-H" isPdfEmbedded="true" />
</fontKey>
<fontKey pdfName="Arial Black" isBold="false" isItalic="false" >
<pdfFont pdfFontName="ariblk.ttf" pdfEncoding="Identity-H" isPdfEmbedded="true" />
</fontKey>
</fontMap>
• APCustomJSReportService.jar, is bundled inside
APJasperExtensions.jar that has to be deployed to the folder
../jasperserver-pro/WEB-INF/lib
• JAR-Dateien kopieren,
Notes • It is possible to specify the name of the file containing the PDF font
map. See the properties of pdfFontMapName above.
iReport Solution
iReport/lib
iReport/classes
• JAR-Dateien kopieren,
Limitations
The font map file has to be located in the classes folder (on the
JasperServer).
Security
APplus and the JasperServer support both the functionality of the user
authorization. The user's permissions are verified when the report is
being executed. By default can everyone render all reports. When we
need to configure the report execution, we use the plugin AccessRight
of the APplus Manager.
• On Rec pages based the generated print and preview menus on the
user´s permission of the current report. If the user doesn't have the
permission for a particular report, the print and preview menus
doesn't contain an entry for the report.
CheckOperation(report.module.documents.report_name |
report.module.statistics.report_name)
Missing Functionality • On Sel pages the grouping option by mandant should be shown
only, if the user has the permissions for all clients.
Setup Of Report The setup of the Report permission is described in the chapter "Jasper
Permission Report Permission Setup" on p. 165.
Configuration
1. Open in the APplus Manager the plugin Zugriffsrechte and open the tab
Autorisierung.
2. You can add a new operation for a particular report with Definitionen >
Operationen and then press the right mouse button and then select the
option Anlegen.
3. For the report angebotAngebot write in the field Name the following:
report.sales.documents.angebotAngebot
4. This step is optional. To add a new role in the APplus Manager open
Definitionen > Rollen and then press the right mouse button and select
the option Anlegen.
Report execution
5. To add permissions to the newly created role you can open the folders
Definitionen > Rollen-Aufgaben-Operationen and then mark one of the
listed users. Next press the right mouse button and select the option
Zuordnung ändern. Open the tab Operationen.
report.sales.documents.angebotAngebot
Verification With the following steps you verify that the access of printing a
proposal will be denied.
1. Open APplus and check that you can load a proposal (Angebot).
report.sales.documents.angebotAngebot
To check the content of the print or preview menu, you must open
APplus and load a proposal.
On the print and preview menu shouldn't be an entry for printing and
previewing the Jasper report for the document.
6. Check now the link invocation. Check that the link that was generated
by printing the document in step 5 can't be viewed.
7. Open the jobs and click on the link of the printed document.
The access should be denied.
Features
• In the APplus Manager open the plugin Reporting and then open the
tab Jasper Integration in the section JasperServer and activate the
checkboxes:
Attention ! This filter runs only if the Tomcat server runs with JDK 1.6 or higher!
To run Tomcat bundled with JasperServer under different JDK. The file
setenv.bat
..\jasperserver\apache-tomcat\bin
How It Works
When we log in to the JasperServer for the first time, we are presented
with the authentication box. It is not the basic authentication dialog,
but NTLM authentication.
During the first login a so called shadow account is created on the
JasperServer. The shadow account gets assigned the JasperServer role:
ROLE_USER
Note: We can't use our windows account to login via the login page of
Jasper. The shadow account created on the JasperServer is marked as
extern and the JasperServer doesn’t consider this account as one of its
own.
in the chapters
and
Introduction
Content The user's permissions are verified when the report is being executed.
By default can everyone render all reports. When we need to control
the report execution, we use the AccessRight plugin of the APplus
Manager. The topic describes how the report permissions are set up and
configured.
../sales/angebotRec.aspx
In the following example we will create a new group with one user and
then switch the access to the report in the APplus manager.
Here you find an overview of the necessary steps. You had to add
1. a new role.
Add a New Role First you add a new role. Open in the APplus manager the plugin
Zugriffsrechte and then open the tab Autorisierung.
Report execution
Add Permissions to
the Newly Created
Role
1. Mark the newly created role and then press the right mouse button and
select the option Zuordnung ändern.
Add a New Operation To add a new operation for a particular report you open in the APplus
For a Particular Manager the plugin Zugriffsrechte and the tab Autorisierung.
Report
1. Open the folder Definitionen and mark the folder Operationen and then
select the option Anlegen.
The APplus Manager opens the dialog Name und Beschreibung.
report.sales.documents.angebotAngebot
Ad Hoc Reporting
Overview Jasper Ad Hoc Reporting is not part of the integration of Jasper Reports
in APplus. Jasper Ad Hoc Reporting is a feature from the JasperServer
that can also be used by APplus users. The user has to log in to the
JasperServer, where the user uses the Ad Hoc Editor to quickly create
reports he needs. The Ad Hoc Reports are based on Topics and
Domains, which has to be created and deployed to the JasperServer
prior to use of the Ad Hoc Editor.
The Ad Hoc Editor and the Ad Hoc Report management are described in
the JasperSoft documentation of the JasperServer
in chapter
About …
… Ad Hoc Reporting
Ad Hoc Reporting Ad Hoc Reporting refers to a type of reporting application that allows
business users to produce their own reports with little technical
knowledge. They must neither be programmers, nor designers. They
don´t need any SQL knowledge and most importantly they must not
wait to get the report.
Ad Hoc Reporting tool Typically an Ad-hoc Reporting tool presents a view of the database's
structure and the user visually drags and drops the fields from the
structure onto the report - specifying any filtering, grouping or sorting
they wish to apply.
The report is then saved and can be pulled up and executed at any time
the user wishes: The report is under total control of the user.
Ad Hoc Editor Part of the JasperServer Pro distribution is also the Ad Hoc Editor. The
Ad Hoc Editor allows end-users to create and refine reports on-the-fly.
We can drag and drop columns and groups, select labels and styles,
select summaries and data formats for each column. The Ad Hoc Editor
is web based and is part of the JasperServer web interface.
Ad Hoc reports are created from Topics and Domains defined by a user
with administrative permissions.
• The Topics, that form the basis of Ad Hoc reports, can be created in
iReport. Topics are usually created as JRXML files. These JRXML files
can only include a query and its parameters; all other report ele-
ments are ignored. Topics must be uploaded to the proper location
in the repository. When an end user clicks Create > Ad Hoc Report
on the Home page of the JasperServer, the list of Topics that
appears on the Topics and Domains page is populated from that
location. Once we have defined and published a Topic, we can use it
to create Ad Hoc reports.
If you installed the sample data, your repository includes Topics and
Domains you can use to explore the Ad Hoc Editor. For more
information about Topics and Domains, see the Documentation of
Jaspersoft
Topic Creation The Topics are usually created by the persons who are familiar with the
data and database schema.
• The simplest way to create Topics is to create new JRXML files using
iReport, then use the iReport plugin of the JasperServer to upload
them to the repository.
Report Authoring Once the Topic is deployed it can be used as a starting point for report
designs.
The design process is straight forward, we just drag and drop fields that
must be displayed, select the fields that are used for grouping and
define summary (summing). The formatting is more or less predefined,
but it is possible to edit the labels and to use predefined styles. If
additional design changes are required, they have to be done in iReport
(after the report is saved).
There you will find the information about three supported report types
(Table, Chart and Crosstab) and a step by step example describing the
creation of a Table Report. The chapter has these sections:
Report Storing After the end of the design phase of the report, the report can be stored
in the JasperServer repository. We can freely select an appropriate
location in the repository and define a suitable report name. The Report
is stored as a report unit that contains only a master report. Once the
report is saved, it is possible to run it from the JasperServer web
interface or via web service request (i.e. from iReport, with the
JasperServer plugin of iReport).
Report Editing Stored reports can be opened and edited in the Ad Hoc Editor and in
iReport. When iReport is used for editing, one has to be aware of the
following:
• adding images,
• changing fonts,
• moving elements.
• Changes made in iReport appear when the report is run, but if the
report is opened in the Ad Hoc Editor, they are not visible.
• Changes made in iReport are lost, when the report is opened in the
Ad Hoc Editor and then saved.
Notes
• When we run an Ad Hoc report, the entire result set is loaded into
the memory cache. We must take care that each Topic’s query
returns a manageable amount of data, depending on the
environment’s load capacity.
• iReport can edit Ad Hoc reports, but the groups and sorting you
defined in an Ad Hoc report will be lost.
Limitations
• Multiple companies are not supported. If topics from more than one
company are present in the adhoc folder, all companies will use the
same DB-connection settings. The issue is present during design
phase.
Quick How To
• create a topic
• deploy a topic
company_name
in the folder
/adhoc/topics
The folder name must be equal to the company name for which
we create Ad Hoc reports (same as it is in reports folder).
/reports/company_name/adhoc
Why to Use Aliases? Sometimes we need to use an alias for a DB field in the SQL SELECT
statement. The reasons could be:
• ADRESSE,
• URSPRUNGSLAND and
• "SYSCONF" (systemconfiguration).
By using derived tables we can enhance the initial statement and get
the information we needed:
SELECT
DERIVED.*,
ULSPRACHE = ursprungsland.sprache
FROM (
SELECT
FIRMANAME=adresse.firma1,
ADRESSNAME=adresse.name,
STRASSE=adresse.strasse,
STRASSE1=adresse.strasse1,
PLZ=adresse.plz,
ORT=adresse.ort,
LANDNAME = isnull(ursprungsland.name, ),
LAND = isnull(ursprungsland.land, ),
MYLAND = (select MYLAND=##Sysconf('stamm', 'myland'))
FROM adresse
LEFT JOIN ursprungsland ON ursprungsland.land = adresse.land
WHERE adresse=$P{DocNrAddress} ) AS DERIVED
LEFT OUTER JOIN ursprungsland on ursprungsland.land =
DERIVED.MYLAND
Note how the initial SQL query is "wrapped" into another query, so that
the alias(es) from the inner query can be used in the outer query.
Problem • Sel page creates the search criteria with the field that is not present
in the table.
wp/wauftragposSel.aspx
• The Sel page creates the search criteria with the field WAUFTRAG
e.g.,
WAUFTRAG=[10;10]
• That is the reason, why the Sel page creates the search criteria
with the field WAUFTRAG.
• The jasper version of the report doesn’t use the view, but
performs the query on the table WAUFTRAGPOS directly.
• To solve the alias issue (alias used in JOIN and WHERE statement),
we have to modify the initial query:
SELECT
ARTIKEL = t.APLAN,
BELEG = t.BAUFTRAG,
t.POSITION,
t.AG ,
ISNULL( t.T_IST , 0 ) AS ISTZEIT ,
ISNULL ( t.T_REST , 0 ) AS T_REST ,
ISNULL ( t.T_SOLL , 0 ) AS SOLLZEIT ,
t.START ,
ISNULL ( t.MENGE , 0 ) AS SOLMENGE ,
ISNULL ( t.MENGE_IST , 0 ) AS ISTMENGE ,
ISNULL ( t.TEPMNG , 1 ) AS TEPMNG ,
ISNULL ( t.MAGR , '(NULL)' ) AS MAGR ,
ISNULL ( t.KOST , '(NULL)' ) AS KOST ,
ISNULL ( t.TE , 0 ) AS TE ,
PROJEKT = COALESCE ( t.projekt , kopf.projekt , '(NULL)' ) ,
ARTIKELNAME = a.name ,
t.KOSTENGRUPPE ,
t.STATUS ,
t.PRIORITAET ,
MAGRNAME = m.name ,
KOSTNAME = k.name_kost ,
ISNULL ( t.ENDE , '01.01.1900' ) AS ENDE
FROM wauftragpos AS t
JOIN WAUFTRAG KOPF ON t.bauftrag = KOPF.bauftrag AND
t.position = KOPF.position
LEFT OUTER JOIN artikel a ON t.aplan = a.artikel
LEFT OUTER JOIN magr m ON t.magr = m.magr AND t.kost =
m.kost
LEFT OUTER JOIN kost k ON t.kost = k.kost
• the alias WAUFTRAG is used in JOIN and can be used in the WHERE
statement or inside the report parameter $P{where}.
WAUFTRAG=[10;10]
Notes Be careful to insert a space between ) and AS, i.e. LEFT OUTER JOIN
kost k ON t.kost = k.kost) AS DERIVED. The string
)AS DERIVED
WHERE $P!{where},
always use
WHERE $P{where}
WHERE WAUFTRAG=[10;10]
Problem We have to create a statistical report that display the range of data
defined on statistical (Sel) page.
The field used for filtering is not present in the DB table or view.
Solution
t.KSTATUS ,
t.VERTRETER ,
t.PERSONAL ,
t.FIRMA ,
t.RADRESSE,
t.PLZ,
t.PROJEKT,
t.ARTIKEL,
a.NAME,
t.ARTIKELGRUPPE,
a.SACHGRUPPE,
t.DATUM ,
t.TERMIN,
t.NETTO ,
t.MANDANT,
t.ANGEBOT ,
t.AUFTRAGSART,
t.STATUS,
t.POSITIONSART,
t.WAEHRUNG
$P!{selFields}
FROM f_auftrag as t
left outer join FIRMA f ON f.firma = t.firma
left outer join vertreter v ON t.vertreter = v.vertreter AND
t.auftragsart = v.auftragsart
left outer join artikel a ON t.artikel = a.artikel
left outer join artikelgruppe gj ON t.artikelgruppe =
gj.artikelgruppe
$P!{selJoin}
) AS derived
WHERE $P{where}
ORDER BY GRUPPE, MONAT, $P{orderby}, BELEG
Since the reports don’t have equal queries and have different
definitions of selFields parameter, this has to be done report by
report.
• BestellungLang and
• AuftragLang
• Custom formatting
##:##:##
Solution An Attempt at a solution you can see in the report srAplanDetails used
in the report aplan.
Use a text field with an expression where the hours, minutes and
remaining seconds are determined manually. In the output of each
them will be separated by colons.
For example the pages of statistical analysis (*Sel.aspx) use the field
DATUM to define a date range in search criteria. We would like that the
field DATUM1 is used when the field DATUM is empty.
1. The input node must contain the second name as an attribute e.g.
<input id='DATUM' name='DATUM' name2='FERTIG' dtType="date">
3. The attribute has to contain the name of the second field for the isnull()
function, e.g. the previous example would produce:
isnull(DATUM,FERTIG)
Notes The isnull() function will become part of the WHERE parameter in the
URL:
... &where=isnull(FERTIG%2CDATUM)%3D[2008-11-
11T00%253A00%253A00;2009-11-11T23%253A59%253A59] ...
And the SelCriteria in the subreport will show the isnull() function:
Examples
modify
<input id='DATUM' name='DATUM' dtType="date">
to
<input id='DATUM' name='DATUM' name2='FERTIG' dtType="date">
modify
<input id='DATUM' name='DATUM' dtType="date">
to
<input id='DATUM' name='FERTIG' name2='DATUM' dtType="date">
modify
<input id='DATUMX' name='DATUMX' dtType="date">
to
<input id='DATUMX' name='FERTIGX' dtType="date">
Note:The name for the second input field must end with X, e.g. change
name='FERTIG' to name='FERTIGX'!
modify
<input type="checkbox" class='P2CHECK' id='EINKAUF' name='EINKAUF' dtType="i2">
to
<input type="checkbox" class='P2CHECK' id='EINKAUF' name='EINKAUF' name2='FIELD2'
dtType="i2">
The field reader was modified and returns now the field list regardless
of the values of the definition of the parameter.
Issue 2 Bei Statistiken, muss ich bei einer Erweiterung immer alle Parameter
(wieder) vorbelegen und danach wieder entfernen (selgroup etc.). Evtl.
gibt es ja noch eine praxistauglichere Lösung.
Solution The field reader was enhanced. It is enough to define the value of the
selGroup parameter (i.e. grouping criteria). The selFields and selJoin
parameters are read from SelParts.xml.
Precondition The file SelParts.xml contains the definitions for the reports for
statistical analysis.
Verification
3. Open the Query Editor and press the button Read Fields.
Index
B Report designs 35
Document
barcode4j.jar 41, 43
Language selection 100
Print 101
C Document output
checked permissions 159 PDF 113
class diagram 128 Document, preview
print server application 128 Language selection 102
classpath 51 Domain
configuration, dynamic 49 Ad Hoc Reporting 168
Common
Tab 131 E
conditional colum
Editing
display extension 42
Resource bundle 95
hide extension 42
env 51
conditional column removing 49
Environments for the first instance
Configuration
Systemconfiguration 48
Change 50
exportToPdf() 155
configuration file 43
Configuration files 44
configuration settings F
mandatory 125 features
configuration, basic 126 print server 123
configuration, extended 126 field
Cultural preferences 80 locale dependant 79
Currency Field,Text
field, locale dependent 80 Style 117
Currency formatting 90 fillReport
Custom Method 132
formatting 89 filterHTML() 119
custom parameters 39 Font
report 34 Unicode 115
custom PDF exporter 42 Font Name 116
Custom tools Font Path 115
reports, localize 82 Font properties 116
CustomAuthenticationFilter 162, 163 Font Properties 113
customize Font, custom (TTF)
preview flow 38 PDF Document 114
print flow 38 Font,inherited
Customized serial printing 37 Operation system 114
fontmap.xml 45, 115, 156, 157, 158
D Formatting
APplus standard 88
data, locale dependent
Formatting,culture-sensitive 86
rendering 93
Date
field, locale dependent 81 G
formatting 88 Global Style Template 111
date field 89
Default style 104
I
Definitionen
folder 165 Identity-H 116
design process Implementation notes
Ad Hoc Reporting 169 Sel.aspx 29
different groupings 25 installation
DocTypes.xml print server 125
Report names 35 Internationalization 79
DocTypes.xml 35 iReport
document Quick facts 11
P R
P2plusJS.aspx 36 redistribute
P2QueryUtils 145 removeColumns parameter 133
p2user 51, 137 remove
P2WebUtils 145 removeColumns parameter 133
Pattern editor remove column
Formatting,culture-sensitive 87 example 133
Pattern, dropdown list limitations 133
Formatting,culture-sensitive 86 removeColumns
PDF parameter 132
Document output 113 Parameter 132
PDF Document removeColumns parameter 131
Unicode Text 115 rendering
PDF Embedded 114, 116 data, locale dependent 93
PDF Encoding 114, 116 report
PDF export 49 new operation 166
PDF Export report authoring 169
Styled Text 121 Report design
PDF export of HTML texts 157 Analysis type 26
PDF file Report Design
Reportexport 114 formatting,culture-sensitive 85
PDF font map 42, 43 Report designs 35
PDF Font Name 114, 116 report editing
PDF output Ad Hoc Editor 170
bold 155 Report format, predefined
HTML tag 155 Statistical analysis 33
italic 155 Report language
pdfFontMapLocation 157 JasperServer 98
pdfFontMapName 157 Report localization support 49
Percent formatting 90 Report name
permission checking Name generation process 26
APplusAuthFilter 162 Report name
permission checks 159 Naming convention 26
Permission Setup Report name
Jasper Report 165 Selection process 31
Preview Report names
Operation flow 19 DocTypes.xml 35
Preview operation Report parameter 39, 51
Server interaction 18 report permission
print flow configuration 160
customize 38 verification 161
Print operation Report processing 131
Operation flow 21 report run
Server interaction 20 Ad Hoc report 170
print server report storing
javadoc documentation 128 Ad Hoc Reporting 170
print server Report style 103
features 123 Report Styles
installation 125 Cascading 104
requirements 124 Report, deploy
start 127 JasperServer 96
Windows service 128 REPORT_LOCALE 80, 94
Print when expression 131, 133 parameter 91
Professional Eition 13 Reportexport
properties 50 PDF file 114
reportFill()
Q method 132
Reporting Services statistik report
query language 137 Systemconfiguration 46
WebServer Adresse 51
WEBSERVICE 137
Zugriffsrechte 165