- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我第一次使用 BIRT 引擎。我专注于使用 POJO 的问题。
我有简单的 POJO:
class Parent {
private String name;
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
简单的 BIRT 报告只打印 parent 姓名(我只打印 1 个 parent 的名字,这意味着 - 我只发送包含 1 条记录的列表)。
我使用 JUnit 测试成功生成了带有父名称的 PDF,而当我尝试在 Tomcat 中生成它时 - BIRT 没有从 POJO 插入值。
你有没有关注过这个问题?
Birt 包装类:
public class BirtRenderer implements IBirtRenderer {
private EngineConfig config;
private IReportEngine engine;
private IReportEngineFactory factory;
public BirtRenderer() throws BirtException {
config = new EngineConfig();
config.setLogConfig("J:\\BirtLogs", Level.WARNING);
// config.setLogger(new Log4jHandler());
Platform.startup(config);
factory = (IReportEngineFactory) Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
engine = factory.createReportEngine(config);
}
public void destroy() {
engine.destroy();
Platform.shutdown();
}
public ByteArrayOutputStream executeReport(String reportName, String fileFormat, @SuppressWarnings("rawtypes") Map context) throws EngineException {
return executeReport(reportName, fileFormat, context, Locale.US);
}
public ByteArrayOutputStream executeReport(String reportName, String fileFormat, @SuppressWarnings("rawtypes") Map context, Locale locale) throws EngineException {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
reportName = reportName + ".rptdesign";
/* for testing */
context = new HashMap();
ArrayList list = new ArrayList();
list.add(new TitleCustomerDao().next());
context.put("APP_CONTEXT_KEY_TITLE_CUSTOMER_DATA", list);
/* for testing end */
InputStream reportStream = this.getClass().getClassLoader().getResourceAsStream(reportName);
if (reportStream == null)
throw new EngineException(new BirtException("File '" + reportName + "' was not found."));
// Open the report design
IReportRunnable design = null;
// design =
// engine.openReportDesign("J:/birt-workspace/test/hello_world.rptdesign");
design = engine.openReportDesign(reportStream);
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
// task.setParameterValue("Top Count", (new Integer(5)));
// task.validateParameters();
RenderOption renderOption = getRenderOption(fileFormat);
renderOption.setOutputStream(outputStream);
task.setRenderOption(renderOption);
// task.setParameterValue("APP_CONTEXT_KEY_PARENTS", data);
task.setAppContext(context);
if (locale != null)
task.setLocale(locale);
if (!task.validateParameters()) {
throw new IllegalArgumentException("Parameters do not validate");
}
task.run();
task.close();
return outputStream;
}
private RenderOption getRenderOption(String fileFormat) {
if (fileFormat.equalsIgnoreCase("pdf")) {
PDFRenderOption PDF_OPTIONS = new PDFRenderOption();
// PDF_OPTIONS.setOutputFileName("J:/birt-workspace/test/hello_world.pdf");
PDF_OPTIONS.setOutputFormat("pdf");
return PDF_OPTIONS;
} else if (fileFormat.equalsIgnoreCase("html")) {
HTMLRenderOption HTML_OPTIONS = new HTMLRenderOption();
// HTML_OPTIONS.setOutputFileName("J:/birt-workspace/test/hello_world.html");
HTML_OPTIONS.setOutputFormat("html");
return HTML_OPTIONS;
} else
return null;
}
}
经过长时间的调查,我发现问题出在哪里。
问题是我在使用 BIRT 的同一 Web 项目中使用 Apache FOP 库。如果我们要了解细节 - 问题出在 Apache Batik 库上,它被 Apache FOP 1.0(使用 >=1.7 Batik)和 BIRT 4.4.2(使用 1.6)使用。
奇怪的是,为什么 BIRT Runtime Java 库里面会覆盖 Batik groupIds 和 artifacts。
您对如何在同一个 Web 项目中使用 Apache FOP 和 BIRT 4.4.2 运行时 Java 库有什么建议吗?
它还取决于,你在上面指定了哪个依赖项。
使用这个 POM.XML PDF 报告生成成功,所有 POJO 数据都正确绑定(bind):
<dependency>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.eclipse.birt.runtime</artifactId>
<version>4.4.2</version>
</dependency>
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
使用此 POM.XML PDF 报告呈现空 POJO 数据字段:
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.eclipse.birt.runtime</artifactId>
<version>4.4.2</version>
</dependency>
最佳答案
我认为您的 POJO 在 Tomcat 中不起作用,因为您忘记为 BIRT 引擎提供类加载器。尝试添加这个:
import org.eclipse.birt.report.engine.api.EngineConstants;
在你的构造函数中:
config.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOADER_KEY, BirtRenderer.class.getClassLoader());
关于java - BIRT Report using POJOs unning under tomcat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29409381/
是否有将 Crystal Reports .rpt 文件转换为 SQL Reporting 2008 .rdl 文件的免费软件? 最佳答案 您很快就会发现,由于 Crystal 许可限制,这是不允许的
如何将 Crystal Reports 8.0 迁移到 Crystal Reports 2008? 8.0的存储过程的 Crystal 报表在2008年不执行,有人可以帮忙吗? 我们正在使用 Seag
我们有几个执行相同格式操作的报告(例如,如果值在特定范围内,则显示“通过”或“失败”。) 如果没有 Crystal Reports Server,有没有办法在报表之间共享功能,以便它们不需要重复?我知
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
我的 Allure 报告以 MM/dd/yyyy 格式显示日期。我想将格式更改为 dd/MM/yyyy。是否可以在 Allure 报告中设置不同的日期格式? 最佳答案 是的,您可以在 settings
在矩阵报告中是否可以根据父组的值隐藏列? 例如,我有一个名为“value”的列,当包含它的列组具有特定值时,我想隐藏它。 最佳答案 对的,这是可能的。如果您单击该组并在“可见性”选项卡下编辑其属性,您
我有一个 Crystal 报告,它正在打印一个空白页并可以很好地打印报告,但只是使用了这个额外的页面。 完成我的研究,勾选、取消勾选并将正确的公式添加到“新页面之后”选项中,而不是在最后一条记录公式等
我的 PDF 报告有问题,在填充文本字段之前,文本字段中的字符串被截断。丢失字符的数量 (5-6) 不足以超过 textField 的末尾. 我添加了 text.truncate.at.char属性添
如果数据字段“IsVisible”设置为 1,我在 Crystal Report 上有一个文本和绘图,我想隐藏它。有没有简单的方法来做到这一点? 最佳答案 您可以通过转到“部分专家”-> 选择所需部分
我设计了一个 Crystal 交叉表报告。它是这样显示的 col1 col2 col3 行1 行11 val1 val2 val3 行2 行21 val1 val2 val3 但我也想要
我刚刚购买了最新版本的 SAP Crystal Reports,并从他们的网站下载了它。我正在尝试运行 Setup.exe 程序,但是一旦我双击它,我就会收到一条 fatal error 消息,指出
如何在 Crystal Reports 中使用多个非嵌套组? 我想做的一个小例子: - 租车头 --rentals 标题(组) ---出租时间为 01-02-2008 至 01-06-2008 ---
我有一个多列 Crystal 报告,现在我想显示重量和数量列的运行总计。实际报告的图片是这个 但是 Crystal 报表设计器不显示其他列,所以我应该在哪一列计算值。 最佳答案 遵循这种方法: 使用以
在 Crystal Reports 中,运行总计字段和汇总字段有什么区别? (在 Crystal IDE 中,汇总字段位于插入 -> 汇总。可以在字段资源管理器中添加运行总计) (版本 11.5) 最
我正在用 Crystal 开发一份报告,我需要对具有多种不同状态的特定字段进行计数。例如,我的报告中有一个“StatusType”字段,其中包含的值是 "In Process", "Rejected"
我有一份 SSRS 2005 报告,其中包含许多图像。我包含图像的方式是我有一个图像对象,其 URL 设置在 value 属性中。实际图像由同一台服务器上的 IIS 虚拟目录托管。我这样做是因为我需要
我正在尝试打印组的最后一条记录,但表达式 print when group changes: True似乎不起作用。它只是打印该组的所有记录。 (我已经根据用户名对记录进行了分组)。 最佳答案 我遇到
我需要构建一个报告,以四个分组级别显示数据。棘手的部分是:要在这四个级别上显示的实际字段将作为参数传递到报告中。 我现在的主要问题是:如何告诉报告上的文本框不显示参数@X 的值,而是按参数@X 中指定
是否可以确定 Reporting Services 报表中显示的列数,并在单独文本框的可见性表达式中使用它? 我面临以下情况: 我的客户有一个 Reporting Services 2005 报告,其
在 RS 报告中,我有一个矩阵,其 LayoutDirection 属性设置为 RTL(因为它是希伯来语)。我通过从数据集字段列表中拖动一个字段并将其放在矩阵的列标题中来创建一个列组。所以列数是可变的
我是一名优秀的程序员,十分优秀!