从操作类调用 birt 报告

发布于 2024-12-27 08:45:56 字数 258 浏览 7 评论 0原文

我正在 Java EE Struts 2 和 Hibernate 中开发一个用于机票预订的项目。现在我的所有工作都已完成,我必须生成一张票。我不想生成简单的 JSP 或 HTML 票证,而是生成可下载的报告(如 Java 中的 Crystal Reports)。我在一个会话中拥有完整的票证信息(就像在互联网上一样),我可以使用脚本获取 BIRT 报告。

我对 BIRT 完全陌生,想知道如何生成 BIRT 报告,或者如何从我的操作类之一调用其执行引擎。任何现成的例子都会有很大的帮助。

I am developing a project in Java EE Struts 2 and Hibernate for airline reservations. Now my all work is done and I have to generate a ticket. Instead of generating a simple JSP or HTML ticket, I want to generate a downloadable report (like Crystal Reports in Java). I have my entire ticket info in a session that (as on internet) I can get on BIRT report using script.

I am totally new to BIRT and wanted to know how I can generate a BIRT report or maybe call its execution engine from one of my action classes. Any ready example will be a great help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

葬﹪忆之殇 2025-01-03 08:45:56

我猜您正在尝试向客户发送 PDF 票证。请使用以下几行创建模板并传递参数:

ReportAdminServiceRemote  birtAdmService = (ReportAdminServiceRemote)MXServer.getMXServer().lookup(“BIRTREPORT”);
byte[] abyte0 = birtAdmService .runReport(userInfo, reportName, appName, parameterData, filename, “pdf”);

生成字节后,您可以这样做:

public String actionDownload() throws Exception{
    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("Content-Disposition","attachment; filename=\"" + example.pdf+ "\"");
    response.setHeader("Expires", "0");
    response.setHeader("Cache-Control","must-revalidate, post-check=0, pre-check=0");
    response.setHeader("Pragma", "public");

    ByteArrayOutputStream baos = new ByteArrayOutputStream();   
    ByteArrayInputStream bis = new ByteArrayInputStream(abyte0);
    inputStream = bis;
    return SUCCESS;
}

所有积分均归这些页面上的作者所有:

http://www.maximonews.com/?p=65

http://www.coderanch.com/ t/432713/Struts/Struts-Files-DownLoad-Streaming-as

I guess you're trying to send PDF ticket to customers. Please create your template and pass parameters using these lines:

ReportAdminServiceRemote  birtAdmService = (ReportAdminServiceRemote)MXServer.getMXServer().lookup(“BIRTREPORT”);
byte[] abyte0 = birtAdmService .runReport(userInfo, reportName, appName, parameterData, filename, “pdf”);

Once you have the bytes generated you can do this way:

public String actionDownload() throws Exception{
    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("Content-Disposition","attachment; filename=\"" + example.pdf+ "\"");
    response.setHeader("Expires", "0");
    response.setHeader("Cache-Control","must-revalidate, post-check=0, pre-check=0");
    response.setHeader("Pragma", "public");

    ByteArrayOutputStream baos = new ByteArrayOutputStream();   
    ByteArrayInputStream bis = new ByteArrayInputStream(abyte0);
    inputStream = bis;
    return SUCCESS;
}

All the credits goes to authors on these pages:

http://www.maximonews.com/?p=65

http://www.coderanch.com/t/432713/Struts/Struts-Files-DownLoad-Streaming-as

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文