Category: Jaspersoft

An Overview of Jasper Reports Scriptlet Class

Scriplets in Jaspersoft

Scriptlets are sequences of Java code that are executed every time a report event occurs. Values of report variables can be affected through scriptlets. A scriptlet is a java class, which must extend either of the following classes: • net.sf.jasperreports.engine.JRAbstractScriptlet − This class contains a few abstract methods that must be overridden in every implementation. These methods are called automatically by JasperReports at the appropriate moment. The developer must implement all the abstract methods. • net.sf.jasperreports.engine.JRDefaultScriptlet − This class contains default empty implementations of every method in JRAbstractScriptlet. A developer is only required to implement those methods depends upon the needs of their project. The following table lists some of the methods in the above class. These methods will be called by the report engine at the appropriate time, during the report filling phase. Method Description public void beforeReportInit() Called before report initialization public void afterReportInit() Called after report initialization. public void beforePageInit() Called before each page is initialized. public void afterPageInit() Called after each page is initialized. public void beforeColumnInit() Called before each column is initialized. Any number of scriptlets can be specified per report. If no scriptlet is specified for a report, the engine still creates a single […]

Read More +

Jaspersoft Report–Basic Element Properties and Palette

Jaspersoft studio

All elements have a set of common properties. Other properties are specific to the element type. An element’s properties determine its appearance and position on the page. Users can access the properties of a selected element in the Properties view (by default in the upper right area of the UI). In Jaspersoft Studio user place elements within bands (containers). Depending on the elements it contains, the user can change the vertical size of a band. The Palette: Elements appear in the Palette, located by default in the top right of the UI. The palette contains three sub-palettes: Basic Elements: It contains the elements and components available in all editions of Jaspersoft Studio Composite Elements: It contains elements created as combinations of other elements, such as Page Number and Time. Users can add their own composite elements to any palette. Components Pro: contains elements only available in commercial versions of Jaspersoft Studio. This subpalette is not visible in the community edition. DataTerrain with years of experience and reliable experts is ready to assist. We have served more than 200 plus customers in the US and an additional 60 plus customers worldwide. We are flexible in working hours and do not need […]

Read More +

How to create Alternate Row backgroundcolor in Jaspersoft reports

Scriplets in Jaspersoft

Conditional styles combined with some specific report built-in variables can be used to generate alternate row colors in the detail section of Jaspersoft reports. As known, the detail section is repetitive and contains common layout information for records in the dataset. For each record in the dataset, a detail section filling process is called at fill time. Being related to records, one of the most common layouts used for the detail section is the table row layout. And like in any other table, alternate row colors might be needed. To obtain alternate row colors, two things are necessary: 1. To know the current record number in order to determine if it’s odd or even. 2. A conditional style with specific style properties for odd or even rows. The first requirement is accomplished with the help of report built-in counting variables: • REPORT_COUNT – If the row color alternation does not depend on the page, column or group breaks. • PAGE_COUNT – If each new detail page should start with the same row color. • COLUMN_COUNT – If each new detail page column should start with the same row color • <group_name>_COUNT – If each new group of records should start […]

Read More +

Report filling process in Jaspersoft Reports

jaspersoft reports

The main objective of any reporting tool is to produce high-quality documents. Report filling process helps reporting tool to achieve this by manipulating sets of data. The main inputs required for the report-filling process are – • Report Template: Its actual JasperReport file. • Report Parameters : These are basically named values that are passed at the report filling time to the engine. • Data Source: User can fill a Jasper file from a range of data sources like an SQL query, an XML file, a CSV file, an HQL (Hibernate Query Language) query, a collection of Java Beans, etc. The output generated by this process is a .jrprint document which is ready to be viewed, printed, or exported to other formats. The facade class net.sf.jasperreports.engine.JasperFillManager is usually used for filling a report template with data. This class has various fillReportXXX() methods that fill report templates. There are two categories of fillReportXXX() methods in the façade class – • The first type receives a java.sql.Connection object as the third parameter. Most of the times, reports are filled with data from a relational database. This is achieved by – Connect to the database through JDBC. Include an SQL query inside the report […]

Read More +