InetSoft Documentation: Report Programming - Initialization Parameters

Initialization parameters are purely deployment-time parameters. They can only be specified in the configuration file (repository XML file). The parameters are similar to the configured creation parameters both in the types of parameters supported and their internal format in the XML file. The major difference between an initialization parameter and a creation parameter is how they are passed to a replet.

Passing Initialization Parameters

All initialization parameters are packaged into a RepletRequest object, with a request name of RepletRequest.INIT. The RepletRequest object is passed to the init() method of the replet. Since init() method is only called once after a replet is created, the request object is only seen by the replet once during its life cycle. The initialization is done before a replet is called to create a report object, so the values of initialization parameters can control how a report is created.

In many situations, an initialization parameter can be replaced by a configured creation parameter. However, if a replet needs an initialization parameter to configure its internal states, in addition to prompting user input, an initialization parameter has to be used. If the creation parameter is used in the configuration file to control the initialization of the replet, end users will never be prompted for the actual creation parameters.

Conceptually, initialization parameters are for relatively static configuration information and creation parameters are for dynamic reporting parameters. The fact that initialization parameters are only passed to the replet once, while creation parameters are passed to the createReport() method on every invocation, underlines the inherent differences of their intended usage.

Example: Initialization Parameters

To illustrate the use of initialization parameters, we modify our last example to take an initialization parameter called 'templateName'. The parameter specifies the report template file to be used to create the actual report (in this example, ''). We will create a new replet class called 'Replet3' to read in the initialization parameter and load the template file based on the parameter value.

Initialization Parameters

public void init(RepletRequest req) throws
RepletException {
try {
// load the report template
InputStream input = getClass().
getResourceAsStream("/" + req.getParameter("templateName") + ".srt");
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.getMessage());

Notice that we only changed one line of code in this replet. In addition, since initialization parameters are configuration parameters only, they need not be declared like the creation parameters. After we compile this file, we use the Enterprise Manager to add a new replet to the repository.

On the Replet Definition registration screen, enter '/Replet3' for 'Name', select 'Class' for 'Type', enter 'inetsoft.demo.replets.Replet3' for 'Class or Template'.

Click the 'New' button under 'Initialization Parameters'. In the Parameter registration screen, select 'String', enter 'templateName' as the 'Parameter Name', enter 'embeddedtable2' as the 'Parameter Value' and click 'OK'. This parameter will be added as an initialization parameter to the replet definition. We then save the 'Replet Definition'.

After the replet is registered, you can view the replet with the web viewer.

If we later want to change the report template for this replet, the only thing we need to do is to change the initialization parameter in the repository. The replet does not need to be modified or recompiled.

The sortOnHeader initialization parameter

A commonly used initialization parameter is 'sortOnHeader', which enables table sorting when a header cell is selected. This Boolean type parameter can be set in the Enterprise Manager or by creating an initialization parameter through the API.

Setting 'sortOnHeader' parameter through the API

public void init(RepletRequest req) throws RepletException {
RepletRequest rr = new RepletRequest(RepletRequest.INIT);
rr.setParameter("sortOnHeader", new Boolean(true));
Previous: Example of a Parameterized Report