InetSoft Technology: Example of a Report Event Handler

To illustrate the use of the event handler, we add two embedded request links. When a link is clicked on, it sends a CUSTOMIZE request to the replet, which sets the visibility of the report title.
#1 Ranking: Read how InetSoft was rated #1 for user adoption in G2's user survey-based index Read More

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, input);
report = (ReportSheet) builder.read(".");
// load data from data file
InputStream input2 =
getClass().getResourceAsStream("/data/education.csv");
 
ttl = new TextTableLens(input2,",");
ttl.setHeaderRowCount(1);
 
RepletParameters def =
new RepletParameters(RepletRequest.CUSTOMIZE);


def.addBoolean("Show Title", true);
 
def.addParameter("Title", "", null);
def.setVisible("Title", false);
 
RepletParameters def1 = new
RepletParameters(RepletRequest.CREATE);
def1.addParameter("Title", "", null);
 
def1.addBoolean("Show Title", true);
def1.setVisible("Show Title", false);
 
addRepletParameters(def);
addRepletParameters(def1);
 
EventHandler eh = getEventHandler();
RepletRequest q1 =
new RepletRequest(RepletRequest.CUSTOMIZE);
q1.setParameter("Show Title", new Boolean(true));
 
// the following call is equivalent to addRequest()
// except addRequest() also inserts commands to change
// the cursor to HAND when the mouse moves on the link
 
eh.addMouseClickCommand("ShowTitleLink", null,
RepletCommand.sendRequest(q1));
 
RepletRequest q2 =
new RepletRequest(RepletRequest.CUSTOMIZE);
q2.setParameter("Show Title", new Boolean(false));
eh.addMouseClickCommand("HideTitleLink", null,
RepletCommand.sendRequest(q2));
 
} catch(Exception e) {
e.printStackTrace();
throw new RepletException(e.getMessage());
}
}

We can then run the replet and click on the two links ('Show Title' and 'Hide Title') to make the report title visible/invisible.