InetSoft Technology: Example of a Parameterized Report

In our second parameritized report example, scripted below, we modify the last example to add a report creation parameter. We add one parameter to the report for the user to specify the title of the report.

To the right is an example of a finished visual report generated by InetSoft's reporting software.

BI DemoRegister

Creation Parameter

package inetsoft.demo.replets;
import inetsoft.sree.*;
import java.util.*;
import java.awt.*;
import java.text.*;
public class Replet2 extends BasicReplet {
public void init(RepletRequest req) throws
RepletException {
try {

// load the report template
InputStream input = getClass().
Builder builder = Builder.getBuilder(Builder.TEMPLATE,
report = (ReportSheet)".");
// load data from data file
InputStream input2 =
ttl = new TextTableLens(input2,",");
RepletParameters def = new
def.addParameter("Title", "", null);
} catch(Exception e) {
throw new RepletException(e.toString());
public ReportSheet createReport(RepletRequest req) {
// set the data on the template
report.setElement("Table1", ttl);
//set the text value to the title
report.setElement("Text1", req.getString("Title"));
return report;
ReportSheet report;
TextTableLens ttl;

Deploy this replet in the EM (Enterprise Manager) as /Replet2. When this replet is viewed in the Web Viewer, the user will be presented with the parameter dialog screen for 'Title'.

After the user enters the parameter and clicks 'OK', the replet is generated according to the value entered.

Default Parameters

Default parameter values can be configured at replet deployment time. The parameter values are entered at the administration GUI and are stored in the replet XML repository. If the default parameter values are specified in the configuration file, users are not prompted when parameterized replets are requested. Instead, the default values are packaged into a RepletRequest object and quietly passed to the createReport() method.

We will use the same replet class from the previous example and register the class as a different replet. In this case, we also specify the default creation parameter for the report title. In the Enterprise Manager's replet registry, add a new replet with the same details as in the previous example but with a different name '/Replet2N'. Click the 'New' button under 'Creation Parameters'.

In the Parameter registration screen, select 'String', enter 'Title' as the 'Parameter Name', enter 'Student Distribution' as the 'Parameter Value', and click OK. This parameter will be added as a creation parameter to the replet definition. We then save the 'Replet Definition'.

Notice that we use the exact same class as in the previous example; however, we added a default creation parameter for the replet. When this replet is requested, the viewer will display the report directly without prompting the end user.

As shown by this example, it is possible to create one replet class and register it as different replets by defining different creation parameters. To the end users, they are distinct reports with different data. This technique can be used when several reports share similar logic or layout and the differences can be controlled based on the parameters.

Read why choosing InetSoft's cloud-flexible BI provides advantages over other BI options.

Previous: Report Parameter Retrieval

Related Information