apex:repeat
指定する構造に基づいてコレクションのコンテンツを出力できる反復コンポーネントです。コレクションには、最大 1,000 個の項目を含められます。
<apex:pageBlockSection> または <apex:panelGrid> コンポーネント内で使用すると、子 <apex:repeat> コンポーネントが生成したすべてのコンテンツは、単一の <apex:pageBlockSection> または <apex:panelGrid> セルに配置されます。
このコンポーネントを次のコンポーネントの直接の子として使用することはできません。
- <apex:panelBar>
- <apex:selectCheckboxes>
- <apex:selectList>
- <apex:selectRadio>
- <apex:tabPanel>
例
1<!-- Page: -->
2
3<apex:page controller="repeatCon" id="thePage">
4
5 <apex:repeat value="{!strings}" var="string" id="theRepeat">
6
7 <apex:outputText value="{!string}" id="theValue"/><br/>
8
9 </apex:repeat>
10
11</apex:page>
12
13
14/*** Controller: ***/
15
16public class repeatCon {
17
18 public String[] getStrings() {
19 return new String[]{'ONE','TWO','THREE'};
20 }
21
22}上述の例では次の HTML を表示します。
1<span id="thePage:theRepeat:0:theValue">ONE</span><br/>
2
3<span id="thePage:theRepeat:1:theValue">TWO</span><br/>
4
5<span id="thePage:theRepeat:2:theValue">THREE</span><br/>標準コンポーネントの例
1<!-- For this example to render properly, you must associate the Visualforce page
2
3with a valid account record in the URL.
4
5For example, if 001D000000IRt53 is the account ID, the resulting URL should be:
6
7https://Salesforce_instance/apex/myPage?id=001D000000IRt53
8
9See the Visualforce Developer's Guide Quick Start Tutorial for more information. -->
10
11
12
13
14
15<!-- Page: -->
16
17<apex:page standardController="Account">
18
19 <table border="0" >
20
21 <tr>
22
23 <th>Case Number</th><th>Origin</th>
24
25 <th>Creator Email</th><th>Status</th>
26
27 </tr>
28
29 <apex:repeat var="cases" value="{!Account.Cases}">
30
31 <tr>
32
33 <td>{!cases.CaseNumber}</td>
34
35 <td>{!cases.Origin}</td>
36
37 <td>{!cases.Contact.email}</td>
38
39 <td>{!cases.Status}</td>
40
41 </tr>
42
43 </apex:repeat>
44
45 </table>
46
47</apex:page>属性
| 属性名 | 属性型 | 説明 | 必須かどうか | API バージョン | 通用範囲 |
|---|---|---|---|---|---|
| first | Integer | 視覚的に表示されるコレクションの最初の要素。value 属性によって指定されたデータセットの最初の要素のインデックスは 0 です。たとえば、value 属性で指定されている一連のレコードの最初の 2 つの要素を表示しない場合は、first="2" と設定します。 | 10.0 | グローバル | |
| id | String | ページの他のコンポーネントが繰り返しコンポーネントを参照できるようにする識別子。 | 10.0 | グローバル | |
| rendered | Boolean | コンポーネントをページに表示するかどうかを指定する boolean 値。指定されていない場合、この値はデフォルトの true に設定されます。 | 10.0 | グローバル | |
| rows | Integer | 表示されるコレクションの最大項目数。この値がコレクションの項目数より小さい場合、コレクションの最後の項目は繰り返されません。 | 10.0 | グローバル | |
| value | Object | 反復処理されるデータのコレクション。 | 10.0 | グローバル | |
| var | String | 反復内の現在の項目を表す変数の名前。 | 10.0 | グローバル |