rsathish_gandhi Posted July 1, 2009 Share Posted July 1, 2009 I now have my jasper reports working from my JRBeancollectionDataSource in my code! I am just a bit confused about some things...When I am designing reports in iReport, I create the fields from a query, which I can do fine and all, since I'm using a a code JRBeanCollectionDataSource() and passing the argument is list of ejbqueryex: JRBeanCollectionDataSource jrbs = this.getShow();public JRBeanCollectionDataSource getShows(){ listjrbean = new ArrayList(); listjrbean.add(this.getShowSearchResults()); listjrbean.add(this.getEmpmaster1()); return new JRBeanCollectionDataSource(listjrbean); }Also, I have List collections of other persistent objects in the ones I'm fetching for the report and I want a subreport that can list the elements of the list, but I don't understand how to reference those from inside iReport to have it make sense when I'm in the code.when this method invoked jasperPrint_ = JasperFillManager.fillReport(jasperReport, Params, DataSource);i'm getting this error net.sf.jasperreports.engine.JRException: Error retrieving field value from bean : empCode Link to comment Share on other sites More sharing options...
shibinthomas Posted July 2, 2009 Share Posted July 2, 2009 In JRBeanCollectionDataSource(listjrbean) you should add collection of objects/beans. You need to verify bean should have getter and setter for empCode. For Ex class EmpClass { private String empCode; private String empName; public String getEmpCode() { return empCode; } public void setEmpCode(String empCode) { this.empCode= empCode; } ................................... ........... } Link to comment Share on other sites More sharing options...
rsathish_gandhi Posted July 7, 2009 Author Share Posted July 7, 2009 collection of object so i add into List<Object>. so they couldn't find the entity. but i have entity empcode in empmaster.i have a collection of object, but i don't know how to specify the entity in the jrxml. Link to comment Share on other sites More sharing options...
e-sarge Posted June 21, 2010 Share Posted June 21, 2010 I know this is old, but it is left unanswered. For future reference, the JRBeanCollectionDataSource needs to be constructed from a collection of objects of the same type. This is why you don't know how to access items from the collection. I think in your case your getShows() method should return new JRBeanCollectionDataSource(this.getShowSearchResults()). If your subreport also needs information from another source (e.g. from the master report data source) then you need to pass that to the sub-report as a parameter and not in the collection. Stated another way, (except for special scenarios like filtering and grouping) the JRBeanCollectionDataSource should contain the same number of items as the number of detail rows in the sub-report. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now