一种发布参数报表和查询报表方式

需求:润乾报表提供的demo中,发布参数报表模板和查询报表模板是在一个jsp中,在参数报表中选择完参数后,点击查询按钮,刷新整个页面,查询报表根据参数参数不同显示不同的数据。有些客户有这样的需求,在点击查询按钮的时候,只刷新查询报表,不刷新参数报表。

 

分析:这个需求可以这样实现,在一个页面中嵌套两个iframe,一个iframe发布参数报表,另一个iframe发布查询报表。这样两张报表不在同一个jsp,查询报表在刷新的时候就不会影响参数报表了。刷新问题解决了,下面说一下参数传递问题。在点击参数报表的查询按钮的时候,参数是暂存在参数缓存池中,查询报表在运算的时候从参数缓存池中取参数值。润乾报表提供的发布参数报表param标签中有resultPage、target,可以解决参数传递的问题。

 

实现:

发布报表的主页面jsp代码如下:

<%@ page contentType=”text/html;charset=GBK” %>

<%

String path = request.getContextPath();

String basePath = request.getScheme()+”://”+request.getServerName()+”:”+request.getServerPort()+path+”/”;

%>

<iframe name=”param” id=”param” marginheight=”0″ marginwidth=”0″ frameborder=”1″ height=”150″ width=”900″ scrolling=”no”  src=”<%=basePath %>jsp/paramReportTop.jsp”>

</iframe> 

<iframe name=”result” id=”result” marginheight=”0″ marginwidth=”0″ frameborder=”2″ height=”200″ width=”900″ scrolling=”no”  src=”<%=basePath %>/jsp/paramReportBelow.jsp”>

</iframe> 

 

发布参数报表的jsp代码如下:

<%@ page contentType=”text/html;charset=GBK” %>

<%@ taglib uri=”/WEB-INF/runqianReport4.tld” prefix=”report” %>

<table id=”param_tbl” width=”100%” height=”100%” bgcolor=”FFFF00″>

    <tr>

        <td>

            <report:param name=”form1″ paramFileName=”paramTest_one.raq”

                needSubmit=”no”

                target=”result“                 //发布查询报表的iframe

                resultPage=”/jsp/paramReportBelow.jsp” //发布查询报表的jsp

            />

        </td>

    </tr>

    <tr>

        <td>

            <a href=”javascript:_submit( form1 )”><img src=”../images/query.jpg” border=no style=”vertical-align:middle”></a>

        </td>

    </tr>

</table>

 

发布查询报表的jsp代码如下:

<%@ page contentType=”text/html;charset=GBK” %>

<%@ taglib uri=”/WEB-INF/runqianReport4.tld” prefix=”report” %>

<table width=”400″ height=”100%”>

    <tr><td>

        <report:html name=”report1″ reportFileName=”paramTest_two.raq”

            funcBarLocation=”both”

            needPageMark=”no”

            generateParamForm=”no”

            exceptionPage=”/reportJsp/myError2.jsp”

        />

    </td></tr>

</table>

 

页面预览效果:

 

在页面中输入参数值,点击查询按钮后,只刷新查询报表,查询报表参数值也接收到了,如下图

 

 

通过上面的方法就可以实现参数报表和查询报表在同一个页面中,但是点击查询按钮时,只刷新查询报表,不刷新参数报表。

本文标签: