封装打印方法
带参数模板的报表,封装打印方法时,要注意传参。
应用举例
1,如下封装,见下面的jsp代码:
<%@ page contentType=”text/html;charset=GBK” %>
<%@ taglib uri=”/WEB-INF/runqianReport4.tld” prefix=”report” %>
<report:param name=”form1″ paramFileName=”4.4_arg.raq” needSubmit=”yes” />
<report:html name=”report1″ reportFileName=”4.4.raq”
exceptionPage=”/reportJsp/myError2.jsp”
/>
<a href=”#” onclick=”report1_print();return false”>打印</a>
<script language=javascript>
function report1_print() {
document.report1_printIFrame.location = ” http://192.168.0.132:6001/demo/reportServlet?action=2&name=report1&reportFileName=4.4.raq&srcType=file&appletJarName=runqianReport4Applet.jar”;
}
</script>
打印的效果图:
2,如下封装,见下面的jsp代码:
<%@ page contentType=”text/html;charset=GBK” %>
<%@ taglib uri=”/WEB-INF/runqianReport4.tld” prefix=”report” %>
<%
request.setCharacterEncoding(”GBK”);
String paramsId = request.getParameter(”reportParamsId”);
%>
<report:param name=”form1″ paramFileName=”4.4_arg.raq” needSubmit=”yes” />
<report:html name=”report1″ reportFileName=”4.4.raq”
exceptionPage=”/reportJsp/myError2.jsp”
/>
<a href=”#” onclick=”report1_print();return false”>打印</a>
<script language=javascript>
function report1_print() {
document.report1_printIFrame.location = ” http://192.168.0.132:6001/demo/reportServlet?action=2&name=report1&reportFileName=4.4.raq&srcType=file&appletJarName=runqianReport4Applet.jar &reportParamsId=”+”<%=paramsId.toString()% >”;
}
</script>
打印的效果图:
1和2两个页面不同的地方是:
String paramsId = request.getParameter(”reportParamsId”);
reportParamsId=<%=paramsId.toString()%>
将这个reportParamsId传给了打印方法。