You need to sign in to do that
Don't have an account?
How to create a branching wizard?
So we have a custom object in salesforce.com that allows us to build pretty complex product configurations and I would like to create a wizard for this. Straight through wizards are no problem, but what I want to do is create a dynamic wizard to show specific pages based on values selected.
The first page only contains one picklist with a list of our products. Based on what is selected here I would like to forward to a specific page.
Page one:
Picklist values: Product A, Product B, Product C.
If A selected, go to apex page A, if B selected go to apex page B, etc, I struggle with setting up the controller class and handling these if statements.
I would think it would be pretty simple I just struggle with the syntax and code form. You can see what I am trying to do with the branch function.
Here is what I have
Page 1
Controller
The first page only contains one picklist with a list of our products. Based on what is selected here I would like to forward to a specific page.
Page one:
Picklist values: Product A, Product B, Product C.
If A selected, go to apex page A, if B selected go to apex page B, etc, I struggle with setting up the controller class and handling these if statements.
I would think it would be pretty simple I just struggle with the syntax and code form. You can see what I am trying to do with the branch function.
Here is what I have
Page 1
Code:
<apex:page controller="configGuide" tabStyle="Configuration__c"> <apex:sectionHeader title="Configuation Wizard" subtitle="Step 1"/> <apex:form> <apex:pageBlock title="Configuration Type"> <apex:pageBlockButtons> <apex:commandButton action="{!branch}" value="Next"/> </apex:pageBlockButtons> <apex:pageBlockSection> <apex:panelGrid> <apex:outputLabel value="What Type of configuration would you like to build—" for="configType"/> <apex:inputField id="configType" value="{!config.Product__c}"/> </apex:panelGrid> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
Controller
Code:
public class configGuide { Configuration__c config; public Configuration__c getConfig() { if(config == null) config = new Configuration__c(); return config; } public PageReference branch() { if(config.Product__c == 'BIG-IP'){ return Page.BIGStep1;
}
} public PageReference configStep1() { return Page.configStep1; } public PageReference FPStep1() { return Page.FPStep1; } public PageReference BigStep1() { return Page.BigStep1; } public PageReference WJStep1() { return Page.WJStep1; } public PageReference save() { insert config; PageReference configPage = new PageReference('/' + config.id); configPage.setRedirect(true); return configPage; } }
Hope this helps.
Does Page.BIGStep1 use the configGuide controller?
So when the next button is clicked it is calling the branch() method and this is where I need assistance. I am hoping that it can do some simple logic that says if Config.Product__c value is BIG-IP go to BIGStep1, if FirePass go to FPStep1 etc.
Here are some other things I have tried for the branch method trying to get it to work. The error I get for the first two is : Error: Compile Error: Non-void method might not return a value at line 12 column 13, which is the first line inside the branch() method. In the last example it says the getConfig method does not exist.
Thanks for the help on this.
Message Edited by TehNrd on 12-11-2007 09:46 AM
Configuration__c config = getConfig();
if(config.Product__c == 'BIG-IP'){
return Page.BIGStep1;
}
}
Configuration__c config = getConfig();
if(config.Product__c == 'BIG-IP'){
return p;
}
Message Edited by thedge on 12-14-2007 08:20 PM
Message Edited by thedge on 12-14-2007 08:25 PM
At first I copy and pasted and it didnt work but then I typed it out and all is good. I thing the web editor is a little finicky, can't wait for the next toolkit that support VF pages.
Jason