日期:2014-05-16  浏览次数:20295 次

JSP传参数给Birt的两种方法 转

JSP传参数给Birt的两种方法

分类: Birt 1048人阅读 评论 (1) 收藏 举报

关于给报表传值:

如果你不使用birt viewer的话,那就是使用api调你的报表,birt api有设置参数的api.
如果使用birt viewer,直接通过url或者使用birt 标签都是可以的。

?

本文只是用jsp的url方式传递参数给birt报表,然后在birt的sql语句里面使用:

一、第一个中方法:

1、在jsp的URL里面添加所要传递的参数:

http://localhost:8080/birt-web/frameset?__report=test.rptdesign&sample=my+parameter

2、在报表当中添加同名报表参数sample,然后可以添加data set参数关联到报表参数sample,这样data set参数就可以得到从jsp页面传递过来的参数从而作为查询条件。

二、第二种方法:

1、在jsp的URL里面添加所要传递的参数:

http://localhost:8080/birt-web/frameset?__report=test.rptdesign&sample=my+parameter

2、在报表当中添加同名报表参数sample

3、点击 Date Sets,在点中间的"Script"标签,选择BeforeOpen,写上
var sample = params["sample"].value;
if(isample=="null"){
?? this.queryText +="where 1=1" ;
}
else {
?? this.queryText +=" where sample=" + sample ;
}
4、如此设置之后就不用再data set里面设置data set参数。
?
?
?
另一种实现方式:

1.jsp页面设置几个需要传递参数的文本框

jsp代码

[html] view plain copy
  1. < script ? type = "text/javascript" > ????
  2. ????function?search(){?????
  3. ????????var?st ?=? document .getElementById("st").value;//开始日期?????
  4. ????????var?et ?=? document .getElementById("et").value;//结束日期?????
  5. ????????window.location.href ?=? "run?__report=reports/new_report.rptdesign&__parameterpage=false&st=" +st+"& et ="+et;?????
  6. ?????????????????
  7. ????}?????
  8. ????function?print(){?????
  9. ????????var?st ?=? document .getElementById("st").value;//开始日期?????
  10. ????????var?et ?=? document .getElementById("et").value;//结束日期?????
  11. ????????window.location.href ?=? "frameset?__report=reports/new_report.rptdesign&__parameterpage=false&st=" +st+"& et ="+et;?????
  12. ?????????????????
  13. ????}?????
  14. </ script > ????
  15. ??</ head > ????
  16. ???????
  17. ??<