Search code examples
javajasper-reportsjavabeans

Jasper subreport not getting datasourcebeans sub object property


I am getting error in iReport when during subreport compilation:

Errors compiling E:\workspace_new\kidslake\src\main\resources\admissionForm_sub_1.jasper!
Compilation exceptions: com.jaspersoft.ireport.designer.compiler.ErrorsCollector@28f84e61  
net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file: 
1. The method getFullName() is undefined for the type Object                 
value = ((java.lang.Object)field_director.getValue()).getFullName(); //$JR_EXPR_ID=17$                                                                       
2. The method getFullName() is undefined for the type Object                 
value = ((java.lang.Object)field_director.getOldValue()).getFullName(); //$JR_EXPR_ID=17$                                                                          
3. The method getFullName() is undefined for the type Object                 
value = ((java.lang.Object)field_director.getValue()).getFullName(); //$JR_EXPR_ID=17$                                                                       
3 errors      
at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:204)     
at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:512)     
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)     

My bean class is like

 class Mainclass{
     private List<AdmissionForm> admissionForm;
     //getter
     //setter
 }

 class AdmissionForm{
    private Director director;
    //getter
    //setter
 }

 class Director{
    private String fullName;
    //getter
    //setter
 }

I am passing JRBeanCollectionDataSource as list of MainClass in my main report

I defined subreport and pass field like new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{admissionFormList})

I define to access director fullname property in my subreport

$F{director}.getFullName()

but when i compile main report or subreport getting the error above.

Help me to resolve my issue


Solution

  • You can do one of the following:

    1. Set the type of the director report field to Director (full/qualified class name). Apparently the current field type is java.lang.Object
    2. Change the report language to Groovy.
    3. Declare a report field called director.fullName and use the field directly instead of $F{director}.getFullName()