Report parameter validation message with Birt

可紊 提交于 2019-12-23 20:24:01

问题


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.

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.

Error:

org.eclipse.birt.report.service.api.ReportServiceException: The validation for parameter "nummonths" fails.

Current script:

if (params["nummonths"].value > 12 )
    {
    false;
    } 
else
    {
    true;
    }

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.


回答1:


You could create a dynamic text styled as a warning, and hide it (property "visibility") with an expression such

params["nummonths"].value <= 12

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.

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;
}

Alternatively, you could also drop some report elements in "beforeFactory" when the parameter is wrong.



来源:https://stackoverflow.com/questions/22771359/report-parameter-validation-message-with-birt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!