问题描述
我想根据报表中数据集/动态文本中的值显示两个图像。 尝试执行操作时出现错误。
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"