Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2017
    Posts
    2
    Rep Power
    0

    Red face ireport eclipse problens

    Good afternoon, I do not know if I'm doing something wrong, I already researched and even found a lot on the internet and even here in the forum but I can not make it work, my problem is this: I have this class students
    public class Alunos{
    public String Nome;
    public void setNome(String Nome) {
    this.Nome= Nome;
    }
    public String getNome() { // pode mudar
    return Nome;
    }
    }

    I have a connection class that from a list of student enrollments creates students objects and adds in a list of Students:

    Method of connection class:

    public static List getAprovados(List siape, String Id_Curso) throws Exception {
    ArrayList Alunos= new ArrayList<Alunos>();
    String lista[]=null;
    for(int i =0; i< siape.size();i++){
    Alunos alunos = new Alunos();
    String sql = "SELECT * FROM Aprovados WHERE Id_Curso ="+Id_Curso+ " AND Siape_CPF="+siape.get(i);
    PreparedStatement stmt = getConnection().prepareStatement(sql);
    //stmt.setString(1, nome);
    ResultSet rs = stmt.executeQuery();
    while (rs.next()) {
    alunos.setNome(rs.getString("Nome_Aluno"));
    //alunos.setId_Certificado(rs.getString("Id_Certific ado"));
    // alunos.setEmail(rs.getString("Email"));
    //alunos.setSiape_CPF(rs.getString("Siape_CPF"));
    }
    Alunos.add(i, alunos);

    rs.close();
    }

    return Alunos;
    }


    I want from this list of Students to generate my reports in ireport so this follows my class to generate reports


    public class Buscar_XML
    {

    String exportPath;
    //private String path; //Caminho base

    //private String pathToReportPackage = "/home/jhonnymcosta/Área de Trabalho/certificados IREPORT/";// Caminho para o package onde estão armazenados os relatorios Jarper

    //Recupera os caminhos para que a classe possa encontrar os relatórios
    public Buscar_XML() {
    JFileChooser fc = new JFileChooser();


    fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
    int res = fc.showOpenDialog(null);
    if(res == JFileChooser.APPROVE_OPTION){
    File diretorio = fc.getSelectedFile();

    exportPath = fc.getSelectedFile().getAbsolutePath();// pega todo o endereco da pasta
    }
    else{
    JOptionPane.showMessageDialog(null, "Voce nao selecionou nenhum diretorio.");}

    System.out.println(exportPath);
    // this.pathToReportPackage = export

    }

    //Imprime/gera uma lista de Clientes
    public void imprimir(ArrayList alunos) throws Exception
    {
    ArrayList<Alunos> novo = new ArrayList<Alunos>();
    novo = alunos;
    // Map<String, String> nomes = new HashMap<String, String>();


    for(int i = 0;i<novo.size();i++){System.out.println(novo.get(i ).Nome);}
    //System.out.println(novo.get(1).getId_Certificado() );
    JRBeanCollectionDataSource beanBurritoWrap = new JRBeanCollectionDataSource(novo);

    JasperReport report = JasperCompileManager.compileReport(exportPath);
    System.out.println(exportPath);
    JasperPrint print = JasperFillManager.fillReport(report, null, beanBurritoWrap);
    System.out.println("aquiii");
    JasperExportManager.exportReportToPdfFile(print, "/home/jhonnymcosta/Área de Trabalho/q/tseste.pdf");
    }

    public String getPathToReportPackage() {
    return this.exportPath;
    }

    }


    Please note that my Search_XML, as I have different report templates I have created a way to fetch the appropriate report,
    No matter what I do, the error always appears:

    Exception in thread "main" net.sf.jasperreports.engine.JRException: Error retrieving field value from bean : Nome
    at net.sf.jasperreports.engine.data.JRAbstractBeanDat aSource.getBeanProperty(JRAbstractBeanDataSource.j ava:123)
    at net.sf.jasperreports.engine.data.JRAbstractBeanDat aSource.getFieldValue(JRAbstractBeanDataSource.jav a:96)
    at net.sf.jasperreports.engine.data.JRBeanCollectionD ataSource.getFieldValue(JRBeanCollectionDataSource .java:100)
    at net.sf.jasperreports.engine.fill.JRFillDataset.set OldValues(JRFillDataset.java:818)
    at net.sf.jasperreports.engine.fill.JRFillDataset.nex t(JRFillDataset.java:782)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.next (JRBaseFiller.java:1433)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller. fillReport(JRVerticalFiller.java:108)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill (JRBaseFiller.java:908)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill (JRBaseFiller.java:830)
    at net.sf.jasperreports.engine.fill.JRFiller.fillRepo rt(JRFiller.java:85)
    at net.sf.jasperreports.engine.JasperFillManager.fill Report(JasperFillManager.java:624)
    at Certificado.Buscar_XML.imprimir(Buscar_XML.java:71 )
    at Certificado.Lista_Alunos.(Lista_Alunos.java:24)
    at Certificado.Teste_Date.main(Teste_Date.java:7)
    Caused by: java.lang.NoSuchMethodException: Unknown property 'Nome'
    at org.apache.commons.beanutils.PropertyUtilsBean.get SimpleProperty(PropertyUtilsBean.java:1122)
    at org.apache.commons.beanutils.PropertyUtilsBean.get NestedProperty(PropertyUtilsBean.java:686)
    at org.apache.commons.beanutils.PropertyUtilsBean.get Property(PropertyUtilsBean.java:715)
    at org.apache.commons.beanutils.PropertyUtils.getProp erty(PropertyUtils.java:290)

    please help me

  2. #2
    benji2505 is offline Senior Member
    Join Date
    Sep 2014
    Location
    MA, USA
    Posts
    398
    Rep Power
    5

    Default Re: ireport eclipse problens

    3rd paragraph from the bottom: you have a for loop that prints out the Nomes of all Alunos in the novo collection. Instead of using the property Nome, try to use the getter method getNome().
    Tip: looping over collections is easier with something like
    for( Alunos alunos:novo){sysout(alunos.getNome())}

    ... and please use [code] tags.

  3. #3
    Join Date
    Mar 2017
    Posts
    2
    Rep Power
    0

    Default Re: ireport eclipse problens

    Hello benji 2505 thank you very much for your attention, this part of the code:
    ArrayList<Alunos> novo = new ArrayList<Alunos>();
    novo = alunos;
    // Map<String, String> nomes = new HashMap<String, String>();


    for(int i = 0;i<novo.size();i++){System.out.println(novo.get(i ).Nome);}
    //System.out.println(novo.get(1).getId_Certificado() );
    I use only to check if my list was not empty.


    I've made changes to the code getting like this but it still has the same problem:

    public void imprimir(ArrayList alunos) throws Exception
    {

    JRBeanCollectionDataSource beanBurritoWrap = new JRBeanCollectionDataSource(alunos);

    JasperReport report = JasperCompileManager.compileReport(exportPath);
    System.out.println(exportPath);
    JasperPrint print = JasperFillManager.fillReport(report, null, beanBurritoWrap);
    System.out.println("aquiii");
    JasperExportManager.exportReportToPdfFile(print, "/home/jhonnymcosta/Área de Trabalho/q/tseste.pdf");
    }

    public String getPathToReportPackage() {
    return this.exportPath;
    }


    thank you so much

Similar Threads

  1. reporting with ireport
    By hitesh in forum Advanced Java
    Replies: 1
    Last Post: 12-07-2010, 12:27 PM
  2. iReport
    By Freddie in forum Advanced Java
    Replies: 6
    Last Post: 04-20-2010, 06:25 PM
  3. About iReport
    By HotEvilGirl in forum New To Java
    Replies: 1
    Last Post: 05-06-2009, 01:07 PM
  4. jsp and ireport
    By sbuggle in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 07-25-2008, 09:25 AM
  5. Eclipse+ireport
    By Nick15 in forum Eclipse
    Replies: 2
    Last Post: 05-14-2007, 04:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •