• 検索結果がありません。

JRXML レポートユニットを編集する

ドキュメント内 JasperReports Server CP User Guide JP (ページ 68-71)

レポートを開いて編集します。設定値を確認してください。もし問題を発⾒できなければ、SalesByMonthさ んぷるレポート(リポジトリの/reports/sample にあります)を編集し、その設定を比較します。

If you get an error when you run the report, open it for editing as described in 3.5, “Editing JRXML Report Units,” on page 55. Review your settings. If you can’t find the problem, edit the SalesByMonth sample report (in the repository at /reports/samples) and compare its settings to your report.

Scriptlet JAR によって書かれたメッセージ 7 を⾒るためには、Report Viewer で をクリックし、レポートの最後の ページに移動します。

To see the message written by the scriptlet JAR on the last page of the report, click in the Report Viewer.

3.4 段階入 ⼒コントロールをレポートに追加する

JRXML ベースのレポートには、動的な値を持つ⼊⼒コントロールを含めることができます。その値は、他の⼊⼒コントロール でユーザが選択した値に依存します。例えば、レポートが「国」、「州」、「町」という⼊⼒コントロールを持っているとします。

「州」⼊⼒コントロールにおける選択肢は、「国」⼊⼒コントロールで選択された値に依存します。ユーザが「州」を選択する ときには、「州」の選択肢は、選択された「国」に依存する値の集合となります。このような段階⼊⼒コントロールは、各⼊⼒

7 【訳注】最後にちんまりと「I’m a scriptlet in a jar」と表示されます。

コントロールラに表示する値を決定するためにクエリを使用します。

JRXML-based reports can include input controls that have dynamic values. The values depend on a user's selection in other input controls. For example, a report has input controls for country, state, and city. The options in the State input control depend on the value selected in the Country input control. When the user selects a state, the list of values includes only those in the selected state. These cascading input controls use queries to determine the values to display in each input control field.

⼊⼒コントロールを、別の⼊⼒コントロールを事前に設定するクエリのパラメータとして使うには、その⼊⼒コントロールのク エリが持つパラメータ名を参照するための特別な文法を使います。その文法は、JasperReports のクエリの中で使われる $P{パ ラメータ名} ⽂法と同じです。⼊⼒コントロールのクエリを定義する⽅法については、「3.3.2.5 クエリベース⼊⼒コントロー ルを追加する」(p.61)を参照してください。

To use input controls as parameters for a query that populates another input control, you use a special syntax to reference a parameter name in the input control's query. The syntax is identical to the $P{parameterName} syntax used in queries for JasperReports. For more information about defining the input control’s query, see section 3.3.2.5,

“Adding a Query-Based Input Control,” on page 49.

例えば、「国」と「町」によって絞り込まれるデータを表⽰するレポートがあるとします。そのレポートには、COUNTRY, CITY と呼ばれる⼊⼒コントロールが含まれています。CITY⼊⼒コントロールで使⽤される以下のクエリは、COUNTRY⼊⼒

コントロールによって選択された値をベースとする accounts というテーブルから国名を取得します。

SELECT city FROM accounts WHERE country = $P{COUNTRY}

For example, a report returns data identified by country and city. It includes input controls called COUNTRY and CITY. This query used by the CITY input control retrieves city names from a table called accounts based on the value selected by the COUNTRY input control:

select city from accounts where country = $P{COUNTRY}

ユーザが COUNTRY⼊⼒コントロールで国を選択したとき、その値がCITY⼊⼒コントロールのクエリで使⽤されます。CITY

⼊⼒コントロールは、その結果を反映するよう更新されます。クエリ内でパラメータを使うためには別の⽅法もあるということ に注意してください。

When the user selects a country from the COUNTRY input control, the value selected is used by the query of the CITY input control; the CITY input control is refreshed to show the result. Note that there are other ways to use a parameter in a query.

段階⼊⼒コントロールを使ったレポートの例については、「2.2.2段階⼊⼒コントロール」(p.20)を参照してください。

For an example of a report that has cascading input controls, see section2.2.2, “Cascading Input Controls,” on page 18.

3.5 JRXML レポートユニットを編集する

リポジトリにレポートユニットを追加した後に、その任意の要素(ファイルリソースや⼊⼒コントロールなど)を編集すること ができます。本節では、曖昧な Text Input Controlのテキスト表⽰を修正する例について説明します。

After you add a report unit to the repository, you can edit any of its elements, including file resources and input controls. This example modifies the display text of the ambiguous Text Input Control.

コンプレックスレポートサンプルを編集するには:

1. 管理者としてログインし、[表示] > [リポジトリ] を選択します。

Log into the server as an administrator and select View > Repository.

⼀般ユーザとしてログインした場合、⾃分で作成したレポートは編集することができます。この例では、管理 者が作成したコンプレックスレポートを編集するので、管理者でのログインが必要となります。

If you log in as a user, you can edit a report that you created. This example requires an administrator login because an administrator created the complex report.

2. リポジトリパネルを閲覧または検索し、対象となるレポートを⾒つけます。今回のサンプルレポートは、Root > Reports

> Samples フォルダにあります。

Search or browse the repository to locate the report. In this example, go to Root > Reports > Samples.

3. 「New Complex Report」を右クリックし、コンテクストメニューから [編集] を選択します。

すると、jasperReportウィザードはそのレポートを開きます。

Right-click the New Complex Report and select Edit from the context menu.

The JasperReport wizard opens the report.

4. 変更したいページまで移動します。今回は、「コントロールとリソース」をクリックします。

Navigate to the page of the wizard for making the change; in this example, click Controls & Resources.

5. ⼊⼒コントロールプロンプトとディスプレイモードを変更します。例えば、以下のようになります。

Make changes to an input control prompt and the display mode of the input controls, for example:

a. [Text Input Control] をクリックします。

すると、「プロンプトの選択」ページが表示されます。

Click the name of the Text Input control.

The Locate Input Control page shows that this input control is locally defined.

b. [次へ] ボタンをクリックします。

「プロンプトの作成」ページが表示されます。

Click Next.

The Create Input Control page appears.

c. 「プロンプトのテキスト」欄の内容を、”Enter a number” に変更し、[次へ] ボタンをクリックします。

「データタイプの選択」ページが表示されます。ここで、リポジトリから別のデータタイプを選択することもできま す。今回は、現在のデータタイプ設定のままとします。

Change the contents of the Prompt Text field to Enter a number.

The Locate Datatypes page appears. You can select a different datatype from the repository. For this example, accept the existing datatype setting.

d. [次へ] ボタンをクリックします。

In Locate Datatypes, click Next.

e. 「データ タイプの種類とプロパティの設定」ページで、[保存] ボタンをクリックします。

In Set the Datatype Kind and Properties, click Save to accept the datatype property settings.

6. 「コントロールとリソース」ページで、以下の⼿順を実⾏します。

On the Controls & Resources page:

a. 「表示モード」を [ページ] に変更します。

Change the Display Mode to In Page.

b. 「常にプロンプトを表示する」のチェックを外します。

Clear the Always prompt check box.

c. [送信] ボタンをクリックします。

Click Submit.

7. 「New Complex Report」を再び実⾏します。

レポートの表示前にポップアップが表示されることはなく、代わりに、「オプション」パネルがレポートの横に表示されま す。

図 3-29 では、テキスト⼊⼒コントロールに「Enter a number」という新しいプロンプトが表⽰されています。この例で は⼊⼒必須である⼊⼒コントロールはないので、レポートは空欄の⼊⼒コントロールをもって実⾏されます。値を⼊⼒し [適用] ボタンをクリックすると、その⼊⼒に従ってレポート出⼒が修正されます。

Run the New Complex Report again.

Instead of appearing in a pop-up before the report; the input controls appear in the Options panel of the report.

Figure 3-29 shows the new prompt, Enter a number, for the text input control. Because none of the input controls in this example are required, the report can run with blank input controls. Enter values and click Apply to modify the report output according to your input.

図 3-29 修正されたレポートの出⼒

ドキュメント内 JasperReports Server CP User Guide JP (ページ 68-71)