Field Types and Preview

This tip relates to managing checkboxes and file fields , which in Jaspersoft Studio becomes Class Type and java.io.Boolean and java.io.File respectively. Also numeric record names deserves attention.

The template file

The template file uploaded to IS Tools requires the correct Class Type setting to work. Depending on which fields are present in the report template and then ending up in the template , replacements may be needed. It is easy to perform replacements in the source view , where the template is displayed in XML format .

Source View
Source View in JasperReports Studio

Preview

In Jaspersoft Studio there are different view modes. In addition to the design view and source view there is also the preview view . This makes the process of creating a template considerably easier, especially with a populated report template in Excel format.

A Data Adapter can with the information from the Excel format deduce the Class Type which is used in Jaspersoft Studio . This is important also for the preview view which on changing Class Type can stop working, with a resulting error message.

Preview View
Preview View in JasperReports Studio

Record names may require attention when contents is numeric, such as in the case of a generated series . Jaspersoft Studio may then assign it as java.lang.Double which makes some expressions such as new Boolean($F{Site Data} != "") fail, since it compares a java.lang.Double with a java.lang.String . A safer expression in such case is new Boolean($F{Site Data}.toString() != "") .

Workflow

If a template where replacements have been made need adjusting, it is possible to first right-click the report name under Outline , and choose Dataset and Query . Then the fields can be re-read with Read Fields , which will reset the Class Type to values working with the preview view .

In cases where Class Type java.io.Boolean and/or java.io.File needs replacing with java.io.String , this should be the last activity before the template is saved and exported to have the preview view enabled as long as possible.

PDF Template Workflow
Workflow

More tips