Using Events of the Report Render Process
Our sample projects and report templates can help you learn the basics of working with our products.This sample project shows how to add and use the handlers for the report render events.
First, create the
For example, we use the 'SimpleList' report. Load this report template and add a Demo database to the report object:
To demonstrate the call order of events at report rendering, we will add several handlers. Each handler will add the text in the text area on the application form:
In the screenshot below you can see the result of the sample code:

First, create the
JFrame and set the necessary options:
public static void main(final String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
JFrame frame = new JFrame();
frame.add(new EventsOfTheReportRenderProcess(frame));
frame.setSize(FRAME_SIZE);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
} catch (Throwable e) {
StiExceptionProvider.show(e, null);
}
}
});
}
For example, we use the 'SimpleList' report. Load this report template and add a Demo database to the report object:
final StiReport report = StiSerializeManager.deserializeReport(new File("Reports", "SimpleList.mrt"));
StiXmlDatabase xmlDatabase = new StiXmlDatabase("Demo", "Data/" + "Demo.xsd", "Data/" + "Demo.xml");
report.getDictionary().getDatabases().add(xmlDatabase);
To demonstrate the call order of events at report rendering, we will add several handlers. Each handler will add the text in the text area on the application form:
report.handlerBeginRender.add(new StiEventHandlerListener() {
public void invoke(StiEventObject myEvent) {
appendText(beginRender);
}
});
report.handlerRendering.add(new StiEventHandlerListener() {
public void invoke(StiEventObject myEvent) {
appendText(subProcessField1);
}
});
report.handlerRendering.add(new StiEventHandlerListener() {
public void invoke(StiEventObject myEvent) {
appendText(subProcessField2);
}
});
report.getPages().get(0).handlerBeginRender.add(new StiEventHandlerListener() {
public void invoke(StiEventObject myEvent) {
appendText(subProcessField3);
}
});
report.getPages().get(0).handlerEndRender.add(new StiEventHandlerListener() {
public void invoke(StiEventObject myEvent) {
appendText(subProcessField4);
}
});
report.handlerEndRender.add(new StiEventHandlerListener() {
public void invoke(StiEventObject myEvent) {
appendText(finishField);
}
});In the screenshot below you can see the result of the sample code:
