Using Events of the Report Render Process
Unsere Beispiele der Projekte und Berichtsvorlagen helfen Ihnen, die Grundlagen der Arbeit mit unserer Software zu erlernen.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:
Auf dem Screenshot unten Sie können das Ergebnis des Beispiel-Codes ansehen:

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);
}
});Auf dem Screenshot unten Sie können das Ergebnis des Beispiel-Codes ansehen:
