サンプル 1 - パラメータの設定

以下の例では、Country パラメータを持つレポート用にパラメータ フィールドを設定する方法を示す JSP ページを取り上げます。各パラメータを設定すると、レポートが表示されます。

注    このチュートリアル サンプルで使用されるすべてのレポートには、適切な JDBC データ ソースが設定され、お使いのアプリケーション サーバーからアクセス可能になっている必要があります。この例で使用したレポートは、チュートリアルには含まれていません。

ParameterFieldsViewReport.jsp

<%@ page import="com.crystaldecisions.report.web.viewer.*" %>

<%@ page import="com.crystaldecisions.sdk.occa.report.data.*"  %>

<%@ page import="com.crystaldecisions.reports.sdk.ReportClientDocument" %>

<%

    Object reportSource = session.getAttribute("reportSource");

    if (reportSource == null)

    {

       String report = "/reports/sample.rpt";

       ReportClientDocument reportClientDoc = new ReportClientDocument();

       reportClientDoc.open(report, 0);

       reportSource = reportClientDoc.getReportSource();

       session.setAttribute("reportSource", reportSource);

    }

    Fields fields = new Fields();

    ParameterField pfield1 = new ParameterField();

    Values vals1 = new Values();

    ParameterFieldDiscreteValue pfieldDV1 = new ParameterFieldDiscreteValue();

    pfield1.setName("Country");

    pfield1.setReportName("");

    pfieldDV1.setValue("Spain");

    pfieldDV1.setDescription("The country is Spain.");

    vals1.add(pfieldDV1);

    pfield1.setCurrentValues(vals1);

    fields.add(pfield1);

    CrystalReportViewer viewer = new CrystalReportViewer();

    viewer.setReportSource(reportSource);

    viewer.setParameterFields(fields);

    viewer.setEnableParameterPrompt(false);

    if (session.getAttribute("refreshed") == null)

    {

viewer.refresh();

session.setAttribute("refreshed", "true");

    }

    viewer.setOwnPage(true);

    viewer.processHttpRequest(request, response, getServletConfig().getServletContext(), null);

%>



Business Objects
http://japan.businessobjects.com/
サポート サービス
http://japan.businessobjects.com/services/