13.07.2015 Views

iReport Ultimate Guide - Nimsoft Library

iReport Ultimate Guide - Nimsoft Library

iReport Ultimate Guide - Nimsoft Library

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>iReport</strong> <strong>Ultimate</strong> <strong>Guide</strong>Variables are the only objects for which a scriptlet can change the value. Pay attention to the fact that when a scriptlet sets avalue for a variable, it could be in concurrence with the reporting engine (in general when a calculation type has been set forthe variable). For this reason, variables that are supposed to be used by a scriptlet should always have System as calculationtype.Being able to access the report objects, not just their value, is a great advantage, especially when a scriptlet is thought to bereusable (since you can identify, for instance, a parameter or field having a certain custom property). In particular, theJRFillParameter and JRFillField provide a way to read the their properties set at design time, and both JRFillFieldand JRFillVariable expose the previous value, which is useful for differential calculations.18.5 Debugging a ScriptletUnfortunately, there is no way to run a step-by-step debugger to debug a scriptlet by setting breakpoints in the code, but thereare several techniques to monitor the scriptlet execution. One of them is using a simple System.out.println() toprint informations that will appear in the <strong>iReport</strong> output console. It is good practice to follow the println call with a flush tobe sure the printed message is shown as soon as possible in the output view. Here is an example:public void beforePageInit() throws JRScriptletException {pageInitTime = new java.util.Date().getTime();}System.out.println("I have set the pageInitTime to: " + pageInitTime);System.out.flush();340

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

Saved successfully!

Ooh no, something went wrong!