JRBeanCollectionDataSource nao alimenta relatorio

Boa noite pessoal estou estudando JasperReport com o iReport e estou tendo problema para alimentar o relatório utilizando um JRBeanCollectionDataSource

segue abaixo o código de execução:

RelCliente.java

[code]/*

  • To change this template, choose Tools | Templates
  • and open the template in the editor.
    */
    package teste;

import br.tebosoftware.dao.sujeito.ClienteDAO;
import br.tebosoftware.entity.sujeito.Cliente;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import javax.swing.JFrame;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.view.JasperViewer;

/**
*

  • @author Shubacca
    */
    public class RelCliente {

    public static void main(String[] args) throws ClassNotFoundException, SQLException {
    JasperPrint jasperPrint;
    try {
    String path = System.getProperty(“user.dir”);
    ClienteDAO dAO = new ClienteDAO();

         List<Cliente> clientes = dAO.getByNome("%");
         jasperPrint = JasperFillManager.fillReport(
                 path + "/reports/RelCliente2.jasper", new HashMap(), new JRBeanCollectionDataSource(clientes, false));
    
         JasperViewer viewer = new JasperViewer(jasperPrint);
         viewer.setExtendedState(JFrame.MAXIMIZED_BOTH);
         viewer.setZoomRatio(1.25f);
         viewer.setVisible(true);
     } catch (JRException e) {
         e.printStackTrace();
     }
    

    }
    }[/code]


agora segue o arquivo do JasperReport

RelCliente2.jrxml

[code]<?xml version="1.0" encoding="UTF-8" ?>






<field name="pessoaFisica" class="java.lang.Boolean">
    <fieldDescription><![CDATA[pessoaFisica]]></fieldDescription>
</field>
<field name="ativo" class="java.lang.Boolean">
    <fieldDescription><![CDATA[ativo]]></fieldDescription>
</field>
<field name="dataNascimento" class="java.util.Date">
    <fieldDescription><![CDATA[dataNascimento]]></fieldDescription>
</field>
<field name="celular" class="br.tebosoftware.customtypes.Telefone">
    <fieldDescription><![CDATA[celular]]></fieldDescription>
</field>
<field name="numero" class="java.lang.Integer">
    <fieldDescription><![CDATA[numero]]></fieldDescription>
</field>
<field name="endereco" class="br.tebosoftware.entity.endereco.Endereco">
    <fieldDescription><![CDATA[endereco]]></fieldDescription>
</field>
<field name="cnpj" class="br.tebosoftware.customtypes.Cnpj">
    <fieldDescription><![CDATA[cnpj]]></fieldDescription>
</field>
<field name="observacao" class="java.lang.String">
    <fieldDescription><![CDATA[observacao]]></fieldDescription>
</field>
<field name="dataCadastro" class="java.util.Date">
    <fieldDescription><![CDATA[dataCadastro]]></fieldDescription>
</field>
<field name="inscricaoEstadual" class="java.lang.String">
    <fieldDescription><![CDATA[inscricaoEstadual]]></fieldDescription>
</field>
<field name="cpf" class="br.tebosoftware.customtypes.Cpf">
    <fieldDescription><![CDATA[cpf]]></fieldDescription>
</field>
<field name="nome" class="java.lang.String">
    <fieldDescription><![CDATA[nome]]></fieldDescription>
</field>
<field name="fax" class="br.tebosoftware.customtypes.Telefone">
    <fieldDescription><![CDATA[fax]]></fieldDescription>
</field>
<field name="rg" class="java.lang.String">
    <fieldDescription><![CDATA[rg]]></fieldDescription>
</field>
<field name="telefone" class="br.tebosoftware.customtypes.Telefone">
    <fieldDescription><![CDATA[telefone]]></fieldDescription>
</field>

    <background>
        <band height="0"  isSplitAllowed="true" >
        </band>
    </background>
    <title>
        <band height="0"  isSplitAllowed="true" >
        </band>
    </title>
    <pageHeader>
        <band height="36"  isSplitAllowed="true" >
            <staticText>
                <reportElement
                    x="0"
                    y="0"
                    width="148"
                    height="18"
                    key="staticText-1"/>
                <box></box>
                <textElement>
                    <font pdfFontName="Helvetica-Bold" size="14" isBold="true"/>
                </textElement>
            <text><![CDATA[Relatório de Clientes]]></text>
            </staticText>
            <textField isStretchWithOverflow="false" pattern="dd/MM/yyyy HH.mm.ss" isBlankWhenNull="false" evaluationTime="Report" hyperlinkType="None"  hyperlinkTarget="Self" >
                <reportElement
                    x="336"
                    y="0"
                    width="199"
                    height="18"
                    key="textField"/>
                <box></box>
                <textElement textAlignment="Right">
                    <font/>
                </textElement>
            <textFieldExpression   class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Report" hyperlinkType="None"  hyperlinkTarget="Self" >
                <reportElement
                    x="336"
                    y="18"
                    width="199"
                    height="18"
                    key="textField"/>
                <box></box>
                <textElement textAlignment="Right">
                    <font/>
                </textElement>
            <textFieldExpression   class="java.lang.String"><![CDATA["Página " + $V{PAGE_NUMBER} + " de " + $V{PAGE_NUMBER} + ""]]></textFieldExpression>
            </textField>
        </band>
    </pageHeader>
    <columnHeader>
        <band height="0"  isSplitAllowed="true" >
        </band>
    </columnHeader>
    <detail>
        <band height="12"  isSplitAllowed="true" >
            <staticText>
                <reportElement
                    x="0"
                    y="0"
                    width="39"
                    height="12"
                    key="staticText-3"/>
                <box></box>
                <textElement>
                    <font pdfFontName="Helvetica-Bold" isBold="true"/>
                </textElement>
            <text><![CDATA[Nome:]]></text>
            </staticText>
            <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
                <reportElement
                    x="39"
                    y="0"
                    width="428"
                    height="12"
                    key="textField-1"/>
                <box></box>
                <textElement>
                    <font/>
                </textElement>
            <textFieldExpression   class="java.lang.String"><![CDATA[$F{nome}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <columnFooter>
        <band height="0"  isSplitAllowed="true" >
        </band>
    </columnFooter>
    <pageFooter>
        <band height="10"  isSplitAllowed="true" >
            <line direction="TopDown">
                <reportElement
                    x="0"
                    y="0"
                    width="535"
                    height="0"
                    key="line-1"/>
                <graphicElement stretchType="NoStretch"/>
            </line>
            <staticText>
                <reportElement
                    x="0"
                    y="0"
                    width="246"
                    height="10"
                    key="staticText-2"/>
                <box></box>
                <textElement>
                    <font pdfFontName="Helvetica-Bold" size="8" isBold="true"/>
                </textElement>
            <text><![CDATA[Tebo Software  -  (16) 3012-1851  -  Franca /SP]]></text>
            </staticText>
        </band>
    </pageFooter>
    <summary>
        <band height="0"  isSplitAllowed="true" >
        </band>
    </summary>
[/code]

E quando executo o programa, não lista nada além das bandas de cabeçalho e rodapé. E o objeto clientes tem 3 objetos do tipo Cliente.

alguém podeia me ajudar nessa?

desde já agradeço

Hum…
Bem, essa sua consulta vem de uma consulta no banco?
Só pra tirar uma duvida, faz um teste com objetos preenchidos na mão (mocks), e tirar esse false na linha

Não é a solução para o problema, mas somente pra tentar sabe que tipo de erro está acontecendo.
Abraços.
:wink:

JL

O resultado vem do banco de dados sim,
e com ou sem esse parametro, não funciona…
o estranho que continuei a informar os campos que necessitava, e um deles funcionou (observação) os demais não.
Conferi os nomes dos filelds e estão todos certinho… não sei o q fazer nao…
rs

valeu

Deu certo, o problema que estava tendo era que o campo estava com um tamnaho menor que o mínimo…
tem como resolver esse problema?

grato