Report Template Replet API

InetSoft's advanced reporting software includes a Java style API for controlling many aspects of report production in a programmatic fashion.

View 2-min Demo
Register for Pricing
 

When a template is registered as a replet, the replet engine uses TemplateReplet class to create a replet Java object internally. If a template-based replet requires user interactions, such as drilldown or customization, the interactions have to be added as Java event handlers. Most of these features can be implemented using the Scripting capabilities in the Designer.

#1 Ranking: Read how InetSoft was rated #1 for user adoption in G2's user survey-based index Read More

Event Handlers

Event handlers can be added to a TemplateReplet like any other BasicReplet. The TemplateReplet class extends the BasicReplet class. Therefore, all BasicReplet methods are available in the TemplateReplet. The event handlers can be added in the init() method of the replet.

public class MyReplet extends TemplateReplet {
   public void init(RepletRequest req) throws
   RepletException {
     setTemplate("http://myhost/templates/mytemplate.srt");
     super.init(req);
 
     addLink("Chart1", "Guide/Details");
   }
}

Template File Location

Because a replet class extending the TemplateReplet is registered as a regular replet, the template file location is not saved as part of the repository. Therefore, the replet class needs to explicitly pass the information to the TemplateReplet during initialization. In the simplest case, the template resource name or URL can be hardcoded in the replet class. The template location can also be configured in the repository as one of the initialization parameters.

public class MyReplet extends TemplateReplet {
   public void init(RepletRequest req) throws
   RepletException {
      setTemplate((String)req.getParameter("template"));
      super.init(req);
 
      addLink("Chart1", "Guide/Details");
   }
}

Because the template is loaded during the TemplateReplet initialization, the setTemplate() call must be made before the super.init() is called. The init() method of the TemplateReplet must be called in the init() method of the replet class. It loads a template file into the program. After the replet is initialized, BasicReplet methods can be used to add interactions to the report.

It is not necessary to use the TemplateReplet to handle report queries. A replet can also use the query engine API to programmatically execute queries and handle query parameters.

Summarizing the Use of Report Objects

A report object can be created in a replet using only the reporting API, or loaded from a report template. If a template does not contain data query information, the report data needs to be programmatically passed in from the replet.

A replet can also be built from a template with embedded queries. The queries are processed using the InetSoft query engine. When designing a report in the Report Designer and binding data queries to the template, there is no need to write any code to create a replet. The report object information is self-contained in the template.

Previous: Query Parameter Handling