Reputation: 143
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
Upvotes: -1
Views: 94
Reputation: 143
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);
Upvotes: 0
Reputation: 141
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.
Upvotes: 2