TherecordSetVarattribute of the<apex:page>tag allows a Visualforce page to handle multiple records, which is ideal for list buttons that display a page for bulk editing. Why not other options? A: Standard controllers can be extended, but usingrecordSetVaris the direct and best-supported method for this scenario. B: There is no such concept as a "Custom List Controller" in Visualforce. C:<spex:listButton>is not a valid Visualforce tag. Visualforce Standard Controller with RecordSetVar
最新のコメント (最新のコメントはトップにあります。)
正解は **D** です。
提供されたドキュメントの「Visualforce ページとコントローラーの構成」セクションに基づき解説します。
### 正解の解説
**D. 標準コントローラと recordsetvar ページ属性 (Standard controller with recordSetVar page attribute)**
[cite\_start]Visualforce ページで「複数のレコード」のリストを処理し、リストボタンから呼び出せるようにするには、**標準リストコントローラー (Standard List Controller)** を使用する必要があります [cite: 1204]。
[cite\_start]この標準リストコントローラーを有効にするための構文は、`<apex:page>` タグ内で以下の2つの属性を指定することです [cite: 1205]。
1. **`standardController`**: 対象のオブジェクト(例: "Account")を指定します。
2. **`recordSetVar`**: レコードのコレクション(リスト)を格納する変数名(例: "accounts")を指定します。
[cite\_start]この属性 (`recordSetVar`) を追加することで、バックエンドのクラスが単一レコード用の `StandardController` から、複数レコード用の `StandardSetController` に切り替わります [cite: 1456]。これにより、チェックボックスで選択された複数のレコードを受け取り、一括編集などの処理が可能になります。
### 不正解の解説
**A. カスタム リスト コントローラー拡張を備えた標準コントローラー**
これは **不正解** です。
標準コントローラーだけでは単一レコードしか扱えません。リスト(複数レコード)を扱うためには、必ず `recordSetVar` 属性が必要です。拡張(Extension)は機能を追加するものですが、ベースとなるコントローラーの定義(リストかどうか)はページ属性で決まります。
**B. recorasetvar ページ属性を持つカスタム リスト コントローラ**
これは **不正解** です。
`recordSetVar` 属性は、**標準コントローラー (`standardController`) とセットでしか使用できません**。カスタムコントローラー (`controller="MyClass"`) を指定した場合、`recordSetVar` 属性は使用できず、エラーになります。カスタムコントローラーでリストを扱う場合は、独自にリスト変数を定義するコードを書く必要があります。
**C. コントローラ拡張と [apex:listButton](https://www.google.com/search?q=apex:listButton) タグ**
これは **不正解** です。
`<apex:listButton>` という標準タグは...