使用Birt报告参数验证消息 [英] Report parameter validation message with Birt
问题描述
我正在使用某些参数创建BIRT报告.我有一个int参数(月数"),值可以从1到12.
I'm creating a BIRT report using certain parameters. I have an int parameter (Number of months) which values can be from 1 to 12.
我需要检查该值是否大于12.在这种情况下,它应该向我显示一条自定义消息,而不是像现在这样显示错误.
I need to check if the value is bigger than 12. In such case it should show me a customized message and not an error like it is doing right now.
错误:
org.eclipse.birt.report.service.api.ReportServiceException: The validation for parameter "nummonths" fails.
当前脚本:
if (params["nummonths"].value > 12 )
{
false;
}
else
{
true;
}
我在BIRT中创建报告以将其上传到IBM Maximo Asset Management系统.在Maximo中,也许有另一种方法可以解决此问题.
I create reports in BIRT to upload it to IBM Maximo Asset Management system. Maybe there is a different way to solve this in Maximo.
感谢您的宝贵时间!希望会帮助别人.
Thanks for your time! Hopefully will help others.
推荐答案
您可以创建一个样式为警告的动态文本,并使用诸如
You could create a dynamic text styled as a warning, and hide it (property "visibility") with an expression such
params["nummonths"].value <= 12
如果选择的国家超过10个,则在此处有这样一种方法的示例或超过10个指示器,则报告顶部会显示一个警告标签.
There is an example of a such approach here, if we select more than 10 countries or more than 10 indicators, a warning label is displayed at the top of the report.
有趣的一点是,尽管显示警告,但我们还可以创建规则来替换onCreate之类的脚本中错误的参数值.这样,报告可以正确运行.例如,在您的情况下,我们可以在脚本中执行以下操作:
An interesting point is, although a warning is displayed we can additionally create a rule to replace the wrong parameter value in a script such onCreate. This way the report can correctly run. For example in your case, we could do in a script:
if (params["nummonths"].value > 12){
params["nummonths"].value=12;
}
或者,当参数错误时,也可以在"beforeFactory"中删除一些报表元素.
Alternatively, you could also drop some report elements in "beforeFactory" when the parameter is wrong.
这篇关于使用Birt报告参数验证消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!