Generate report with nested object problem

I have a class with nested object. I'm using Bean Collection DataSource. 


Here is the class of the Transaction bean

public class Transaction {
    private Long idTransaction;
    private String observation;
    private String observation2;
    private DirectionOfTransaction directionOfTransaction;
    private LocalDateTime dateTime;
    private Account account;
    private User user;
    private TypeOfTransaction typeOfTransaction;
    public Long getIdTransaction() {
        return idTransaction;
    public void setIdTransaction(Long idTransaction) {
        this.idTransaction = idTransaction;
    public String getObservation() {
        return observation;
    public void setObservation(String observation) {
        this.observation = observation;
    public String getObservation2() {
        return observation2;
    public void setObservation2(String observation2) {
        this.observation2 = observation2;
    public DirectionOfTransaction getDirectionOfTransaction() {
        return directionOfTransaction;
    public void setDirectionOfTransaction(DirectionOfTransaction directionOfTransaction) {
        this.directionOfTransaction = directionOfTransaction;
    public LocalDateTime getDateTime() {
        return dateTime;
    public void setDateTime(LocalDateTime dateTime) {
        this.dateTime = dateTime;
    public Account getAccount() {
        return account;
    public void setAccount(Account account) {
        this.account = account;
    public User getUser() {
        return user;
    public void setUser(User user) {
        this.user = user;
    public TypeOfTransaction getTypeOfTransaction() {
        return typeOfTransaction;
    public void setTypeOfTransaction(TypeOfTransaction typeOfTransaction) {
        this.typeOfTransaction = typeOfTransaction;

I have problem in JasperSoft community edition. first of all insert my class folder with in class path.

Get Transaction class properties, when i drag & drop field with type like Strin, bigDecimal, to the details section every thing works fine.

But when i drag and drop field declared with custom types like DirectionOfTransaction, Account ..etc (My own class), Japsersoft sutdio can't place them in the details section.

I have also create a variable using some with conditional expression and place in the detail section i get an error:

Here is hte JRXML file:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version using JasperReports Library version 6.2.2  -->
<!-- 2016-06-11T18:35:06 -->
<jasperReport xmlns="" xmlns:xsi="" xsi:schemaLocation="" name="secondReport" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="4a30fc90-411a-46d8-b4f3-ba259634b3cc">
   <property name="" value="New Data Adapter "/>
   <field name="directionOfTransaction" class="bean.DirectionOfTransaction"/>
   <field name="observation" class="java.lang.String"/>
   <variable name="dirVar" class="java.lang.String">
      <variableExpression><![CDATA[((DirectionOfTransaction) $F{directionOfTransaction}).equals(DirectionOfTransaction.CREDIT)) ? "CREDIT" : "DEBIT"]]></variableExpression>
      <band splitType="Stretch"/>
      <band height="79" splitType="Stretch"/>
      <band height="35" splitType="Stretch"/>
      <band height="61" splitType="Stretch">
            <reportElement x="171" y="0" width="100" height="30" uuid="b8ac6d0b-e915-4f42-8f8d-b96378dae6bf"/>
      <band height="48" splitType="Stretch">
            <reportElement x="171" y="18" width="100" height="30" uuid="43d5b9f4-5602-4987-b944-1bd1cd0776de"/>
      <band height="45" splitType="Stretch"/>
      <band height="54" splitType="Stretch"/>
      <band height="42" splitType="Stretch"/>

and her is the code for java program:

try {
    InputStream inputStream = new FileInputStream("./report/secondReport.jrxml");
    JasperDesign jasperDesign = JRXmlLoader.load(inputStream);
    JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
    HashMap parameter = new HashMap();
    JRDataSource beanDataSource = new JRBeanCollectionDataSource(transactionModel.getTransactionList());
    JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameter, beanDataSource);
    if (jasperPrint != null) {
    } else
        System.out.println("Not able to print");
} catch (FileNotFoundException e) {
} catch (JRException e) {

abdeulwahabebouamer's picture
Joined: Jun 11 2016 - 10:24am
Last seen: 6 years 11 months ago

0 Answers:

No answers yet