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...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>iReport</strong> <strong>Ultimate</strong> <strong>Guide</strong>getFieldValue(JRField jrField), returns true if the cursor is positioned correctly in the subsequent record, false ifthere are no more available records.Every time that UR executes the public boolean next() method, all the fields declared in the report are filledand all the expressions (starting from those associated with the variables) are calculated again; subsequently, it will be decidedwhether to print the header of a new group, to go to a new page, and so on. When next returns false, the report is ended byprinting all final bands (Group Footer, Column Footer, Last Page Footer, and Summary). The method can be called as manytimes as there are records present (or represented) from the data source instance.The method public Object getFieldValue(JRField jrField) is called by UR after a call to next resultsin a true value. In particular, it is executed for every single field declared in the report (see Chapter 6 for the details on how todeclare a report field). In the call, a JRField object is passed as a parameter; it is used to specify the name, the description andthe type of the field from which you want to obtain the value (all this information, depending by the specific data sourceimplementation, can be combined to extract the field value).The type of the value returned by the public Object getFieldValue(JRField jrField) method has to be adequate tothat declared in the JRField parameter, except when a null is returned. If the type of the field was declared asjava.lang.Object, the method can return an arbitrary type. In this case, if required, a cast can be used in the expressions. Acast is a way to dynamically indicate the type on an object, the syntax of a cast is:(type)objectin example:(com.jaspersoft.ireport.examples.beans.PersonBean)$F{my_person}Usually a cast is required when you need to call a method on the object that belongs to a particular class.11.6 Data Source Types11.6.1 Using JavaBeans Set Data SourcesA JavaBeans set data source allows you to use JavaBeans as data to fill a report. In this context, a JavaBean is a Java class thatexposes its attributes with a series of getter methods, with the following syntax:public getXXX()where (the return value) is a generic Java class or a primitive type (such as int, double, and so on).In order to create a connection to handle JavaBeans, after clicking New in the Connections/Datasources dialog, selectJavaBeans set data source in the list of data source types to bring up the dialog box shown in Figure 11-13.182

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

Saved successfully!

Ooh no, something went wrong!