英文:
call JasperReports report by RapidClipseX
问题
以下是翻译好的部分:
对于 RapidClipse4,我使用以下代码调用并在新窗口中打开 JasperReport。
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();
}
几个月前,我切换到了 RapidClipseX。但是使用的代码不再起作用。
是否有关于以下内容的经验/示例代码:
- 如何从 RapidClipseX Web 应用程序中调用 JasperReport?
- 如何将其作为 PDF 在新窗口中打开?
(注意:以上内容仅为翻译,不包含回答或其他信息。)
英文:
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?
答案1
得分: 2
这里有一个小例子:
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);
还有一个有用的提示:当您处于代码视图时,在左上角有一个代码调色板中的“Report”条目。当您点击此按钮时,将打开一个向导,它将帮助您创建导入jasper报表所需的代码。
英文:
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.
答案2
得分: 0
使用上面的答案帮助,我按照以下代码使其运行起来:
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);
英文:
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);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论