Birt-onCreate

问题描述

我想根据报表中数据集/动态文本中的值显示两个图像。 尝试执行操作时出现错误。

if(this.getRowData().getExpressionValue("row[price]") == "$30" )
this.imageName = "check.JPG";  
else
this.imageName = "unchecked.JPG"; 

错误:

org.eclipse.birt.report.engine.api.EngineException:评估脚本“ if(this.getRowData()。getExpressionValue(” row [price]“)==” $ 30“)this.imageName =时出错“ check.JPG”;否则this.imageName =“ unchecked.JPG”;“:TypeError:无法调用null的方法“ getExpressionValue”(/ report / body / image [@ id =” 84“] / method [@ name = “ onCreate”]#1)

解决方法

我不知道脚本出了什么问题-显然getRowData()返回null,但我不知道为什么。

无论如何,我将以不同的方式解决此问题,并使用“共享资源中的图像文件”和“资源文件”为您的文件名的图像。该文件名必须是绝对路径或相对于“共享资源”文件夹的相对路径。因此您的文件名表达式将是

row["price"] == "$30" ? "check.JPG" : "unchecked.JPG"

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...