调用JasperReports报表通过RapidClipseX。

huangapple go评论69阅读模式
英文:

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&lt;&gt;())
		.jrxml(&quot;/Simple.jrxml&quot;)
		.exportToResource(Format.Pdf());

final HtmlObject pdfViewer = new HtmlObject(pdf, &quot;application/pdf&quot;);
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(&quot;/frontend/reports/MyReport.jrxml&quot;)
			.dataSource(MyReportDAO.INSTANCE.findAll())
			.mapField(&quot;Beschreibung&quot;, &quot;beschreibung&quot;).mapField(&quot;Status&quot;, &quot;status&quot;)
			.mapField(&quot;Erfassungsdatum&quot;, &quot;erfassungsdatum&quot;).mapField(&quot;StatusAenderungsDatum&quot;, &quot;statusAenderungsDatum&quot;)
			.exportToResource(Format.Pdf());
		
		final HtmlObject pdfViewer = new HtmlObject(pdf, &quot;application/pdf&quot;);
		pdfViewer.setSizeFull();
		this.add(pdfViewer);

huangapple
  • 本文由 发表于 2020年8月15日 21:00:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/63426327.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定