views:

103

answers:

1

I am new to JSF and JasperReports. Can anyone suggest a sample webapplication for JSF with JasperReports which doesn't use a database connection?

+1  A: 

You need to generate pdf from jasper report here are the samples for the same

Here is the code from BalusC blog for rendering PDF in JSF.
If you are using RichFaces then go for a4j:mediaOutput This will load PDF using AJAX.

Sample snippet to create PDF.

String fileName = "C:\\JasperReports\\report.jasper";
        UUID uu = new UUID(3, 4);

        String outFileName =  "C:\\TempReport\\" + uu.randomUUID().toString() + ".pdf";

        hm.put("year", new Integer(y).toString());
        hm.put("timezone", sTimezone);

try {
            JasperPrint print = JasperFillManager.fillReport(
                    fileName,
                    hm,
                    new JREmptyDataSource());
            JRExporter exporter =
            new net.sf.jasperreports.engine.export.JRPdfExporter();
            exporter.setParameter(
            JRExporterParameter.OUTPUT_FILE_NAME,
            outFileName);
            exporter.setParameter(
            JRExporterParameter.JASPER_PRINT, print);
            JasperExportManager.exportReportToPdfFile(print, outFileName);
            print = null;
            exporter = null;
            JasperViewer.viewReport(print,false);
        } catch (Exception e) {
            e.printStackTrace();
        }

Refer this blog for detail

org.life.java
i can't understand. please give me jsf with jasper report step by step.
Vamshikrishna Kapidi
beacuse im new to jsf and jasper reports. i have one pojo class to get the report. not connecting database. only sample example to show the report. like in mybean(name,salary) fields. i am setting the names(kkk,xxx,yyy) and salary(111,222,333). i need just show me the jasper report only using jsf . please help me...........
Vamshikrishna Kapidi
edited the answer.
org.life.java