Visualforce ページへのフロー変数値の取得
フロー変数値は、Visualforce ページに表示できます。フローを Visualforce ページに埋め込むと、Visualforce マークアップを使用して、変数または sObject 変数の値を取得できます。コレクション変数または sObject コレクション変数の値を表示するには、Visualforce マークアップを使用して、コレクションに含まれる個々の値を取得します。
Apex クラスを使用してフローから sObject 変数値を取得し、Visualforce ページに表示する例を次に示します。
1public class FlowController {
2
3 public Flow.Interview.flowname myflow { get; set; }
4
5 public Case apexCaseVar;
6
7 public Case getApexCaseVar() {
8
9 return myflow.caseVar;
10
11 }
12
13}1<apex:page controller="FlowController" tabStyle="Case">
2
3 <flow:interview name="flowname" interview="{!myflow}"/>
4
5 <apex:outputText value="Default Case Priority: {!apexCaseVar.Priority}"/>
6
7</apex:page>次の例では、Apex クラスを使用して、フローの文字列コレクション変数 (emailsCollVar) に保存されている値を取得してから、Visualforce ページを使用してフローインタビューを実行します。Visualforce ページは、フローのコレクション変数を反復処理し、コレクションの各項目の値を表示します。
1public class FlowController {
2
3 public Flow.Interview.flowname myflow { get; set; }
4
5
6
7 public List<String> getVarValue() {
8
9 if (myflow == null) {
10
11 return null;
12
13 }
14
15 else {
16
17 return (List<String>)myflow.emailsCollVar;
18
19 }
20
21 }
22
23}1<apex:page controller="FlowController">
2
3 <flow:interview name="flowname" interview="{!myflow}" />
4
5 <apex:repeat value="{!varValue}" var="item">
6
7 <apex:outputText value="{!item}"/><br/>
8
9 </apex:repeat>
10
11</apex:page>Apex クラスを使用してフローを {!myflow} に設定し、Visualforce ページを使用してフローインタビューを実行する例を次に示します。Visualforce ページは、データテーブルを使用して、フローの sObject コレクション変数を反復処理し、コレクションの各項目の値を表示します。
1public class MyCustomController {
2
3 public Flow.Interview.flowname myflow { get; set; }
4
5}1<apex:page controller="MyCustomController" tabStyle="Account">
2
3 <flow:interview name="flowname" interview="{!myflow}" reRender="nameSection" />
4
5 <!-- The data table iterates over the variable set in the "value" attribute and
6
7 sets that variable to the value for the "var" attribute, so that instead of
8
9 referencing {!myflow.collectionVariable} in each column, you can simply refer
10
11 to "account".-->
12
13 <apex:dataTable value="{!myflow.collectionVariable}" var="account"
14
15 rowClasses="odd,even" border="1" cellpadding="4">
16
17 <!-- Add a column for each value that you want to display.-->
18
19 <apex:column >
20
21 <apex:facet name="header">Name</apex:facet>
22
23 <apex:outputlink value="/{!account['Id']}">
24
25 {!account['Name']}
26
27 </apex:outputlink>
28
29 </apex:column>
30
31 <apex:column >
32
33 <apex:facet name="header">Rating</apex:facet>
34
35 <apex:outputText value="{!account['Rating']}"/>
36
37 </apex:column>
38
39 <apex:column >
40
41 <apex:facet name="header">Billing City</apex:facet>
42
43 <apex:outputText value="{!account['BillingCity']}"/>
44
45 </apex:column>
46
47 <apex:column >
48
49 <apex:facet name="header">Employees</apex:facet>
50
51 <apex:outputText value="{!account['NumberOfEmployees']}"/>
52
53 </apex:column>
54
55 </apex:dataTable>
56
57</apex:page>フローの sObject コレクション変数のコンテンツに応じて、データテーブルは次のようになります。