简体   繁体   中英

call JasperReports report by RapidClipseX

For RapidClipse4 I used following code to call and open a JasperReport in a new window

try {
    this.browserFrame = new XdevBrowserFrame();
    final Resource exportToResource = Report.New()
        .jrxml("WebContent/WEB-INF/resources/reports/MeinReport.jrxml")
        .dataSource( com.xdev.dal.DAOs.get(com.MyReportDAO.class)
                            .parameter("selJahr", selJahr)
                            .mapField("L1_GroupName", "l1GroupName")
                            .mapField("L2_GroupName", "l2GroupName").mapField("dBetrag", "dbetrag")
                            .mapField("JahrMonat", "jahrMonat")
            .exportToResource(ExportType.PDF);

        this.browserFrame.setSource(exportToResource);

} catch (final Exception e) {
    e.printStackTrace();
}

A few months ago I switched to RapidClipseX. But the used code did not more work.

Are there any experience/ sample code to

  • call a JasperReport out of a RapidClipseX Webapplication?
  • open it in a new window as pdf?

Here is a small example:

final StreamResource pdf = Report.New()
        .dataSource(new ArrayList<>())
        .jrxml("/Simple.jrxml")
        .exportToResource(Format.Pdf());

final HtmlObject pdfViewer = new HtmlObject(pdf, "application/pdf");
pdfViewer.setSizeFull();

this.add(pdfViewer);

Also a useful tip: When you are in the code view, in the top left there is a "Report" entry in the code palette. When you click this button a wizard will open that will help you create the code needed to import a jasper report.

With help by the answer above I got it running by following code:

            final StreamResource pdf = Report.New()
            .jrxml("/frontend/reports/MyReport.jrxml")
            .dataSource(MyReportDAO.INSTANCE.findAll())
            .mapField("Beschreibung", "beschreibung").mapField("Status", "status")
            .mapField("Erfassungsdatum", "erfassungsdatum").mapField("StatusAenderungsDatum", "statusAenderungsDatum")
            .exportToResource(Format.Pdf());
        
        final HtmlObject pdfViewer = new HtmlObject(pdf, "application/pdf");
        pdfViewer.setSizeFull();
        this.add(pdfViewer);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM