四:在水晶報表編輯器中編輯我要用的報表.由於我需要動態給報表傳遞參數,所以我在報表中設定了一個參數欄位,水晶報表根據這個參數欄位,就可以顯示相應的
資料,參數欄位命名為BH,在方程式編輯器中編寫如下代碼:
IF {?BH}<>"" THEN
{GG_BPBJ.JLBH}={?BH}
ELSE
{GG_BPBJ.JLBH}="1" OR {GG_BPBJ.JLBH}<>"1"
以上代碼的意思是:如果bh參數不為空白,則顯示{GG_BPBJ.JLBH}等於參數BH的記錄,否則顯示出所有的記錄
(大家可能覺得{GG_BPBJ.JLBH}="1" OR {GG_BPBJ.JLBH}<>"1"很可笑,是啊,我開始是寫成"true"了,在水晶報表編輯器中可以很好的運行,但方到web上顯示就有
問題,萬般無奈,只有如此了,:( )
六:需要特別注意的是:在WEB_INF下的web.xml檔案也隨之改動,改動後的web.xml檔案如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<!-- The web.xml file is a configuration file used to control the behavior of WebLogic server.
In most cases, you will not need to modify this file. For more information on web.xml, please
consult the Web.xml Deployment Descriptor Elements chapter of the "Developing WebLogic Server
Applications" documentation on edocs.bea.com. -->
<web-app>
<display-name>Workshop Application</display-name>
<context-param>
<param-name>weblogic.httpd.inputCharset./*</param-name>
<param-value>GBK</param-value>
</context-param>
<context-param>
<param-name>crystal_image_uri</param-name>
<param-value>/webmis/crystalreportviewers10</param-value>
</context-param>
<filter>
<filter-name>PageFlowJspFilter</filter-name>
<filter-class>com.bea.wlw.netui.pageflow.PageFlowJspFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>PageFlowJspFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<listener>
<listener-class>com.bea.wlw.runtime.core.servlet.WebappContextListener</listener-class>
</listener>
<!-- Standard Action Servlet Configuration (with debugging) -->
<servlet>
<servlet-name>messageServlet</servlet-name>
<servlet-class>com.infoearth.servlets.getTaskServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>com.bea.wlw.netui.pageflow.DynamicSubappActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/jpf-struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>config/-global</param-name>
<param-value>/WEB-INF/jpf-struts-config--global.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
public class ReportInit
{
private IReportSource rptSource;
private Fields fields;
public ReportInit(){
rptSource = null;
fields = null;
}
public IReportSource getRptsource(){
return rptSource;
}
public Fields getFields(){
return fields;
}
public boolean setReport(String fname,String rptID){
//獲得查詢條件
String FileName = fname + ".rpt";
String BH = rptID;
String path = "report/"+FileName; //報表檔案路徑
try{
IReportSourceFactory2 rsf = new JPEReportSourceFactory();
java.util.Locale localetest = java.util.Locale.CHINA;
rptSource = (IReportSource)rsf.createReportSource(path,localetest);
fields = new Fields();
ParameterField pfield1 = new ParameterField(); //編號
ParameterField pfield2 = new ParameterField(); //單位
ParameterField pfield3 = new ParameterField(); //人
ParameterField pfield5 = new ParameterField(); //FIELD5
ParameterField pfield6 = new ParameterField(); //FIELD6
ParameterField pfield4_KSSJ = new ParameterField(); //開始時間
ParameterField pfield4_JSSJ = new ParameterField(); //結束時間
Values vals1 = new Values();
Values vals2 = new Values();
Values vals3 = new Values();
Values vals5 = new Values();
Values vals6 = new Values();
Values vals4_KSSJ = new Values();
Values vals4_JSSJ = new Values();