jeanroch.sales Posted February 21, 2014 Share Posted February 21, 2014 Hello community,i can't get the content of a collection of beans into a table :(here is my bean:public class MyBean { public String header; public String row; public String value; public MyBean(final String header, final String row, final String value) { this.row = row; this.header = header; this.value = value; } public String getHeader() { return header; } public void setHeader(final String header) { this.header = header; } public String getRow() { return row; } public void setRow(final String row) { this.row = row; } public String getValue() { return value; } public void setValue(final String value) { this.value = value; } } And, here is my Factory: public class BeanFactory { /*** @param args*/public static void main(final String[] args) { createBeanCollection(); } public static List<MyBean> createBeanCollection() { // TODO Auto-generated method stubArrayList<MyBean> beans = new ArrayList<MyBean>(); MyBean a1 = new MyBean("header1", "row1", "VALUE11"); beans.add(a1); MyBean a2 = new MyBean("header2", "row1", "VALUE12"); beans.add(a2); MyBean a3 = new MyBean("header3", "row1", "VALUE13"); beans.add(a3); MyBean b1 = new MyBean("header1", "row2", "VALUE21"); beans.add(b1); MyBean b2 = new MyBean("header2", "row2", "VALUE22"); beans.add(b2); MyBean b3 = new MyBean("header3", "row2", "VALUE23"); beans.add(b3); MyBean c1 = new MyBean("header1", "row3", "VALUE31"); beans.add(c1); MyBean c2 = new MyBean("header2", "row3", "VALUE32"); beans.add(c2); MyBean c3 = new MyBean("header3", "row3", "VALUE33"); beans.add(c3); MyBean d1 = new MyBean("header1", "row4", "VALUE41"); beans.add(d1); MyBean d2 = new MyBean("header2", "row4", "VALUE42"); beans.add(d2); MyBean d3 = new MyBean("header3", "row4", "VALUE43"); beans.add(d3); // JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(beans); System.out.println("Done Creating Beans"); return beans;} }So now you're in my universe, can someone explain why:The data adapter receives an incorrect amount of beans (3x)The table does not show data when the report is generatedThe report is waaay too longThank you,best regardsJRS Link to comment Share on other sites More sharing options...
Ankur Gupta Posted February 22, 2014 Share Posted February 22, 2014 Hi ,I have a video made on the same subject have a look You can also go through a artilcle for the same http://ankurthetechie.blogspot.in/2013/12/jrdatasource-as-datasource.htmlDo let me know if you need further helpThanksAnkur Guptahttp://ankurthetechie.blogspot.in/ Link to comment Share on other sites More sharing options...
Solution Ankur Gupta Posted February 22, 2014 Solution Share Posted February 22, 2014 Hi,The other problem which I can see is here is that ,the beans you have created should be at last should be storred in a collection/Array which should be fetched via report.In the case of collection/ Array of beans, it could be looped in the Detail band and that will produce correct results. So Refer to the above links I have posted there are code snippets too . Go through them that will help you get the concept. Hope that this helps. Thanks Ankur Guptahttp://ankurthetechie.blogspot.in/ Link to comment Share on other sites More sharing options...
jeanroch.sales Posted February 24, 2014 Author Share Posted February 24, 2014 Thank you for your help :) I don't understand why I would need to create a custom Datasource when there is a JRBeanCollectionDatasource already implemented. The table is located in the detail band... Do I have to recode the Datasource anyway ? How do I make the report fetch my collection ? From what I read in your articles (very interesting by the way), it shouldn't take long nor be complicated, but still I puzzles me that there is no easier way. As well, what package is JRDataSourceProvider in ? Last note, I use JasperSoft Studio (not iReport, should I use iReport?). Your help is highly appreciated. Link to comment Share on other sites More sharing options...
jeanroch.sales Posted February 24, 2014 Author Share Posted February 24, 2014 I just succeeded in accessing my beans, by using the simple variable (drag & dropped in the details section, created a Label) but I can't get those in a table (as one per line). Something must be missing in the table config. 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