Reports
Heads up! These docs are for Portofino 3, which is a legacy product. Check out Portofino 4!
Copyright 2008-2012 ManyDesigns srl. All rights reserved.
Contents
Purpose
Reports are a very common requirement for most information systems. Reports should allow:- querying the data with filtering, aggregation and sorting;
- good formatting and layout of information;
- on-line viewing and printing.
- Object reports: reports focused on a single object or a small group of related objects, e.g., an invoice or a purchase order. This type of report frequently results in a printed document.
- System reports: reports over large amounts of data, e.g. a sales report.
You can access the JasperReports class from the system's tabs.
Attributes
The JasperReports class has the following attributes.In the Basic information group:
- Class: is specified, the report is an object report for objects of the class. If unspecified, the report is a systems report.
- Name: the report's name.
- Location: the location of the .jrxml or .jasper file containing the report's definition. The location must be a valid resource in the classpath, e.g.: com/example/myproj/myreport.jasper
- Description: a short description.
- Attachment: if checked, the user's browser will save the report to the local disk. If unchecked, the browser will try to display the report inside the browser's window. This is just a suggestion Portofino gives to browsers. the actual behaviour may vary depending on the browser's configuration and installed plug-ins.
- Csv: comma-separated values
- Html
- Rtf: Rich Text Format
- Txt: plain text
- Xls: Microsoft Excel
Creating the report definition
To create the report definition file (either a .jrxml or a .jasper) you have to use an external tool like iReport or Jasper Assistant.Portofino version 3.1.x uses JasperReports 3.5.0. If you use iReport, for compatibility, make sure you download iReport 3.5.0 or 3.5.1.
When you have created and tested the report definition outside Portofino, you can make it available to Portofino by copying the .jrxml or .jasper to the classpath. For example, if you entered "com/example/myproj/myreport.jasper" in the location field, a convenient location for the definition file would be "WEB-INF/classes/com/example/myproj/myreport.jasper" in your web application folder. You may have to restart your application server to make changes visible.
If possible, compile your report into a .jasper file. These speeds up Portofino's start-up.
Predefined parameters
JasperReports supports parameterized reports. Parameters are defined in the parameter elements of the .jrxml.For example:
<parameter name="id" isForPrompting="true" class="java.lang.Integer"/>
<parameter name="schema1" isForPrompting="false" class="java.lang.String">
<defaultValueExpression ><![CDATA["model"]]></defaultValueExpression>
</parameter>
<parameter name="schema2" isForPrompting="false" class="java.lang.String">
<defaultValueExpression ><![CDATA["meta"]]></defaultValueExpression>
</parameter>
Parameters id, schema1 and shema2 are treated specially, as Portofino provides their values at run-time:
- id: the id of the object (applicable only to object reports)
- schema1: the value of the configuration parameter model.schema
- schema2: the value of the configuration parameter meta.schema
These parameters are useful in the .jrxml section where you define the report query. For example:
<queryString><![CDATA[SELECT p."code", p."title"
FROM "$P!{schema1}"."project" p
WHERE p."id"=$P{id}]]></queryString>
Other parameters
In addition to the predefined parameters, you can specify any other custom parameters you need to run your report. Portofino will prompt the user to enter the values.
To use this feature:
- in the .jrxml define the parameters using the parameter elements;
- in the .jrxml use the parameters where you need them, for instance in the queryString element;
- at the upstairs level, define the JasperReports object, then create the parameters in theJasperReports parameter section.
A JasperReports parameter has the following attributes:
- Name: the name of the parameter. This much match the name you use in the .jrxml definition.
- Label: a user-friendly label for the parameter.
- Force value: if specified, Portofino uses this value without prompting the user. If unspecified, Portofino prompt the user for a value.
Permissions
In the Visible by user groups section you can specify which user groups are allowed to run the report. If not user groups are specified (which is the situation for newly created reports), the report can be run by all users.Reports are not model-driven
If you change your application model, the changes are not automatically propagated to the reports. Make sure you review the queryString and field elements in your .jrxml files to aling them with the model.
Previous: Portals and portlets
Next: BLOBs