iReport Ultimate Guide - Nimsoft Library

iReport Ultimate Guide - Nimsoft Library iReport Ultimate Guide - Nimsoft Library

13.07.2015 Views

iReport Ultimate GuideFigure 18-10 Simple field debugging windowThe code of the scriptlet is the following:Code Example 18-3 Debugging scriptlet example sourcepublic void beforePageInit() throws JRScriptletException {pageInitTime = new java.util.Date().getTime();String fieldValuesMsg = "";Iterator i = fieldsMap.keySet().iterator();while (i.hasNext()){String fieldName = (String)i.next();fieldValuesMsg += fieldName + " = " + getFieldValue(fieldName) + "\n";}fieldValuesMsg += "\nStop execution?";}if ( JOptionPane.showConfirmDialog(null, fieldValuesMsg,"",JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION){// Stop the executionthrow new JRScriptletException("Execution interrupted by the user");}The dialog will pop up every time a new page is initialized just because we are implementing the method beforePageInitpausing the report execution. If the user selects Yes (stop the execution), the scriptlet throws a JRScriptletException that342

Scriptletsterminates the report execution with the message “Execution interrupted by the user.” This technique can be used toautomatically terminate a process that is taking too much time (until one of the scriptlet events is actually invoked), when weare producing too many pages, and so on.18.6 Deploying Reports That Use ScriptletsSometimes you may create a report that works well in iReport, but that does not work when deployed in an externalapplication. One of the things to check for is whether the report is using a scriptlet. If it is, be sure that the scriptlet classes areavailable in the classpath. Finally, a scriptlet can be used in more than a single report, so consider creating your own library ofscriptlets and putting all of them in a single JAR.343

Scriptletsterminates the report execution with the message “Execution interrupted by the user.” This technique can be used toautomatically terminate a process that is taking too much time (until one of the scriptlet events is actually invoked), when weare producing too many pages, and so on.18.6 Deploying Reports That Use ScriptletsSometimes you may create a report that works well in <strong>iReport</strong>, but that does not work when deployed in an externalapplication. One of the things to check for is whether the report is using a scriptlet. If it is, be sure that the scriptlet classes areavailable in the classpath. Finally, a scriptlet can be used in more than a single report, so consider creating your own library ofscriptlets and putting all of them in a single JAR.343

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!