birt報表從session中取引數
阿新 • • 發佈:2019-02-15
自從註冊CSDN沒寫過一篇文章,今天閒來沒事,整理點小東西,寫下來。
birt從session中取從JSP傳遞的引數。
1、把JSP頁面獲得的引數放到session中,以下是簡短程式碼:
<body> <table> <input type="text" id="name" /> <input type="text" id="age"/> <input type="text" id="sex"/> <input type="button" onclick="subAajax()" /> </table>
<iframe name="reportIframe" id="reportIframe" height="82%"
style="width: 100%;z-index:9999;background: url(../images/public/8.gif);"frameborder="0" scrolling="auto" onload="change();">
</iframe>
</body>
<script type="text/javascript"> function subAajax(){ var name=document.getElementById("name"); var age=document.getElementById("age"); var sex=document.getElementById("sex");
var reportIframe = document.getElementById("reportIframe");
var url1="<%= request.getContextPath()%>" + "/frameset?__report=/report/"+reportName+"&__toolbar=false";
var con="&name="+name+"&age="+age+"&sex="+sex;
$.ajax({ url:"<%= request.getContextPath()%>" +"/processRptdesign.do?method=addPosearchParam"+con, //處理頁面 type:"post", dataType:"html", success:function(msg){ $("#reportIframe").attr("src",encodeURI(url1)); } });
}
</script>
public class ProcessParamAction extends DispatchAction { public ActionForward addPosearchParam(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { Map<String, String> map=new HashMap<String, String>(); String name=request.getParameter("name"); String age=request.getParameter("age"); String sex=request.getParameter("sex"); map.put("stime",stime); map.put("name",name); map.put("age",age); map.put("sex",sex); request.getSession().setAttribute( "AppContextKey","numberWhere"); request.getSession().setAttribute("AppContextValue", map); return null; }
2、在報表中取session中的資料,在before open中寫如下程式碼獲取:
var name=numberWhere.get("name");
var age=numberWhere.get("age");
var sex=numberWhere.get("sex");
以上僅供參考,歡迎大家指正,共同學習