please help. i'm trying to create a multipage jrviewer from an arraylist i populated somewhere in my application then passing it as parameters to be displayed in my xml report. i don't know why it is not working, it only generates 2 pages, and the 2nd page contains nothing.

my code:

import java.awt.Dimension;
import java.awt.Toolkit;
import java.util.ArrayList;
import java.util.HashMap;

import javax.swing.JFrame;

import net.sf.jasperreports.engine.JREmptyDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRPrintPage;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.base.JRBasePrintPage;
import net.sf.jasperreports.view.JRViewer;


/**
 * @author dengoy
 */

public class Reports {
 
 static ReportDAO reportDAO = new ReportDAO();
 static ArrayList list = null;
 static JasperReport jasperReport;
 static JasperPrint jasperPrint;
 static HashMap map = new HashMap();
 
 
 public static void main(String[] args) throws JRException {
  
  try {
        
   JRViewer aViewer = new JRViewer(getJasperPrint());
   JFrame aFrame = new JFrame("My Report");
   aFrame.getContentPane().add(aViewer);
   Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
   aFrame.setSize(screenSize.width, screenSize.height);
   aFrame.setLocation(0, 0);
   aFrame.show ();

  }
    
     catch (Exception e) {
      e.printStackTrace();
     }
 }
 
 private static JasperPrint getJasperPrint() throws JRException {
  
  ReportDTO reportDTO = null;
  list = reportDAO.getNames ();
   
  JasperPrint jasperPrint = null;
  JRPrintPage page = new JRBasePrintPage();
   
  for (int i = 0; i < list.size(); i ++) {
   
   reportDTO = (ReportDTO)list.get(i);
   map.put("EMPID", reportDTO.getFname());

   jasperReport = JasperCompileManager.compileReport("C:\\myReport.xml");
   jasperPrint = JasperFillManager.fillReport(jasperReport, map, new JREmptyDataSource());
   jasperPrint.addPage(page);
   
  }
  
  return jasperPrint;
 }
}

 
 
thanks in advance... have a nice day :)

--
Believe those who are seeking the truth; doubt those who find it.
Andre Gide

Reply via email to