No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
Newer Version Available
Advanced Examples of Using <flow:interview>
The <flow:interview> component is designed to make it easy to develop complex Visualforce interactions. However, there are also more features you can access in your flow by creating a custom controller. With custom controllers, you can build a page with multiple components that can interact with each other. Any flow within your organization can be individually referenced by its own Apex type, and the variables in the flow can be accessed as member variables.
1<apex:page Controller="ModemTroubleShootingCustomSimple" tabStyle="Case">
2 <flow:interview name="ModemTroubleShooting" interview="{!myflow}"/>
3 <apex:outputText value="Default Case Prioriy: {!casePriority}"/>
4</apex:page>1public class ModemTroubleShootingCustomSimple {
2
3 // Need not instantiate explicitly the Flow object using the class constructor
4 public Flow.Interview.ModemTroubleShooting myflow { get; set; }
5 public String casePriority;
6 public String getcasePriority() {
7 // Access flow variables as simple member variables with get/set methods
8 if(myflow==null) return 'High';
9 else return myflow.vaCasePriority;
10 }
11}If you're using a custom controller, you can also set the initial values of the variables at the beginning of the flow in the constructor of the flow. Passing in variables using the constructor is optional and isn't necessary if you are using <apex:param> tags to set the value.
1public class ModemTroubleShootingCustomSetVariables {
2 public Flow.Interview.ModemTroubleShooting myflow { get; set; }
3
4 public ModemTroubleShootingCustomSetVariables() {
5 Map<String, Object> myMap = new Map<String, Object>();
6 myMap.put('vaCaseNumber','123456');
7 myflow = new Flow.Interview.ModemTroubleShooting(myMap);
8 }
9
10 public String caseNumber { set; }
11 public String getcaseNumber() {
12 return myflow.vaCaseNumber;
13 }
14}You can use the getVariableValue method in the Flow.Interview class to enable a Visualforce controller to access the value of a flow variable. The variable may be in the flow embedded in the Visualforce page or in a separate flow that is called by a subflow element. The returned variable value comes from whichever flow the interview is currently running. If the specified variable can’t be found in that flow, the method returns null. This method checks for the existence of the variable at run time only, not at compile time.
1swfobject.registerObject("clippy.codeblock-3", "9");public class SampleContoller {
2
3 //Instance of the flow
4 public Flow.Interview.Flow_Template_Gallery myFlow {get; set;}
5
6 public String getBreadCrumb() {
7 String aBreadCrumb;
8 if (myFlow==null) { return 'Home';}
9 else aBreadCrumb = (String) myFlow.getVariableValue('vaBreadCrumb');
10
11 return(aBreadCrumb==null ? 'Home': aBreadCrumb);
12
13 }
14}
15| Flow | Apex |
|---|---|
| Text | String |
| Number | Decimal |
| Currency | Decimal |
| Date | Date, DateTime |
| Boolean | Boolean |
1@isTest
2private class ModemTroubleShootingCustomSetVariablesTest {
3
4 static testmethod void ModemTroubleShootingCustomSetVariablestests() {
5 PageReference pageRef = Page.ModemTroubleShootingSetVariables;
6 Test.setCurrentPage(pageRef);
7 ModemTroubleShootingCustomSetVariables mytestController =
8 new ModemTroubleShootingCustomSetVariables();
9 System.assertEquals(mytestController.getcaseNumber(), '01212212');
10 }
11}Setting the reRender Attribute
By using the reRender attribute, the <flow:interview /> component re-renders the flow without refreshing the whole page:
1<apex:page Controller="ModemTroubleShootingCustomSimple" tabStyle="Case">
2 <flow:interview name="ModemTroubleShooting" interview="{!myflow}"
3 reRender="casePrioritySection"/>
4 <apex:outputText id="casePrioritySection"
5 value="Default Case Prioriy: {!casePriority}"/>
6</apex:page>