如何动态设计分页标签

如何动态设计分页标签

海量数据的清单式列表在读取、展现及导出过程中可能会出现速度过慢、内存溢出、系统死机等问题,分页计算extHtml标签扩展了原html标签的功能,实现了以页为单位对数据进行读取和展现及导出等操作,大大降低了内存占有量,提高了运行效率,避免内存溢出等问题。

分页标签的写法大致为:

<report:extHtml
name="report1"
reportFileName="api/1.6.raq"
totalCountExp="query('SELECT count(*) FROM 订单明细')"
params="<%=param.toString()%>"
scale="1.1"
pageCount="10"
needPageMark="yes"
funcBarFontFace="黑体"
funcBarFontSize="14"
funcBarFontColor="red"
functionBarColor="#FFCCFF"
separator="|"
needSaveAsExcel="yes"
needSaveAsPdf="yes"
needSaveAsWord="yes"
funcBarLocation="top"
needPrint="yes"
firstPageLabel="首页"
prevPageLabel="前一页"
nextPageLabel="后一页"
lastPageLabel="尾页"
printLabel="全打印"
excelLabel="导出excel"
pdfLabel="导出pdf"
wordLabel="导出word"
generateParamForm="yes"
displayNoLinkPageMark="yes"
saveAsName="测试"
startRowParamName="startRow" //起始行参数名,非必填,默认值为startRow
endRowParamName="endRow" //结束行参数名,非必填,默认值为endRow
userFuncBarElements="<a href='http://www.runqian.com.cn'>润乾</a>"
needScroll="no"
scrollHeight="100"
needLinkStyle="yes"
exceptionPage="myErrorPage.jsp"
/>
从上面我们可以看到,这里的totalCountExp属性是写死的,如果想写一个通用jsp,如何来动态设置总记录的表达式呢?
我们可以先在报表里建立一个数据集,这个数据集的sql就是查询总记录条数的,那么,这个数据集就可以在设计报表模版的时候就写好:
m_11_11_1
这样我们就可以在加载报表模版的时候,把这个sql从报表模版里面读取出来,并设置到里面分页标签里面去:
     
     
import com.runqian.report4.model.ReportDefine;
import com.runqian.report4.usermodel.DataSetConfig;
import com.runqian.report4.usermodel.SQLDataSetConfig;
import com.runqian.report4.util.ReportUtils;
public class sqlReadOut {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
// 读取报表模版定义
ReportDefine rd = (ReportDefine)ReportUtils.read("C:\\Program Files\\reportHome\\webapps\\demo\\reportFiles\\初级教程\\3.3.raq");
//取报表模版第一个数据集的对象
SQLDataSetConfig sdc = (SQLDataSetConfig)rd.getDataSetMetaData().getDataSetConfig(1);
//得到sql
String sql = sdc.getSQL();
System.out.println(sql);
}
}
我们获得sql后,可以传递到前台页面,再接收:
String sql = request.getParameter( "sql" );
<report:extHtml
name="report1"
reportFileName="api/1.6.raq" //报表名,必填属性
totalCountExp="<%=sql%>" //总记录数,必填属性
//其值为一个润乾的非数据集函数,返回整型数据。如用query执行一个count的sql。
/>
用同样的方法,还可以设置标签中的其他属性,这样就可以根据不同的报表模版来动态的设置标签的属性了.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值