java - JasperReports accessing to property javabeans -


i´m studying jasperreports , want access property subclass example report.persona.name jasperreport show me error:

net.sf.jasperreports.engine.jrexception: error retrieving field value bean : name caused by: java.lang.nosuchmethodexception: unknown property 'name' on class 'class com.test.dto.report' 

i´m trying accessing

show other errors.

i have 3 dto class

person

public class person {     private int id;    private string name;    private string lastname;    private string age;    ...getter setter 

ticket

public class ticket {     private int number;    private string typeticket;    private string dateticket;    ...getter setter 

and class group both last class

report

public class report {     private person person;    private list<ticket> ticket;    ...getter setter 

a main class call collection(report) , send parameter jrbeancollectiondatasource

main

public class main {  public static void main(string[] args) throws filenotfoundexception, jrexception {      jasperdesign jasperdesign;     jasperprint jasperprint;     jasperreport jasperreport;      try     {         inputstream base = new fileinputstream(new file("c:\\users\\documents\\netbeansprojects\\testreport\\src\\jrxml\\template.jrxml"));          jasperdesign = jrxmlloader.load(base);         //compile          jasperreport = jaspercompilemanager.compilereport(jasperdesign);          jasperprint = jasperfillmanager.fillreport(jasperreport, null,                 new jrbeancollectiondatasource(                         getmydata()));         //view report using jasperviewer         jasperviewer.viewreport(jasperprint);     }     catch (jrexception e)     {         e.printstacktrace();     }   }   private static collection getmydata() {      list<report> data = new linkedlist<report>();     report report = new report();      person p1 = new person();     p1.setname("my name ");     p1.setaage("100");     p1.setlastname("last name");      report.setperson(p1);      data.add(reporte);      // .... comment code list<ticket>     return data; }  } 

well, way jasper-reports deals bean properties, reading them parameters. have create map object store them. example, inside java code (in main class, there code use generate report) have put snippet :

map parameters = new hashmap(); string name = report.person.getname(); parameters.put("name", name);  jasperprint = jasperfillmanager.fillreport(jasperreport, parameters, new jrbeancollectiondatasource(                     getmydata())); 

this way, person's name stored in report class, visible jrxml of report. now, second step use parameter in report, expression like:

$p{name} 

and need.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -