views:

172

answers:

2

Hi friends, I want to print a table in pdf document. I need to use two javabean datasource to populate the data in the table. So i used two subreport parallely to map the data.The problem what i am facing is i could not able to organize the second subreport content corresponding to first subreport.That is , if any field's width is big in the first subreport then content in the second report will not align properly corresponding to the first subreport.The below sample will give a good idea about the problem

My expected Output

       SubReport1                     SubReport2

  S.No     Value                  S.No       Value

   1      value from first         1          value from second bean
          java bean value 
          bean   

   2      value from first bean    2          value from second bean

Result which i am getting

      SubReport1                    SubReport2

   S.No     Value               S.No       Value

   1     value from first        1          value from second bean
         java bean value        2          value from second bean       
          bean   

   2      value from first bean 

Please kindly help me to sort out this problem.

A: 

Subreports are like function arguments. They are evaluated prior to calling the function and don't know about each other. There are two solutions for your problem:

  1. remove both subreports and render data in the main report
  2. append some nonprinting characters to the shorter of two values that are supposed to be rendered in the same row
Boris Pavlović
Hi Boris thanks for your interest.Actually i am using JavaBeanDatasource and my bean returning two ArrayList.so to populate this ArryList values i used Subreport .I hope we can't directly populate ArrayList inside mainreport directly.We cant use nonprinting char also because sometimes second subreport value may be big than the first one.Is there is anyother possiblity?.
Kumar
+1  A: 

As @Boris suggested first thing remove the subreports.

Since you are using BeanDatasource then you can put all the business and logic in your code and give the report a ready made list.

Make a new object, lets call it ReportRow, don't use that name of course :).

public class ReportRow{
    int sNumber1;
    int sNumber2:
    String value1:
    String value2:
    //setters and getters
}

Now create a new ArrayList<ReportRow> and pass at as the datasource.

HTH.

medopal
it seems that kumar doesn't have an access to the source which emits these two arrays
Boris Pavlović