You need to sign in to do that
Don't have an account?
Molson94
VisualForce: Validating URL Parameters When Page Loads
Hi All,
I am looking to create a series of pages that allow for creation of multiple custom objects. The first step however before anything can be rendered or created is to check the 'v' parameter in the URL to ensure that the vendor exists.
i keep running into problems when i look to inslude the logic in the controller constructor. It is my understanding from the documentation that the controller constructor will be processed first, then getter, then actions etc...
The below logic either will not compile, because the contrstor cannot return a value, and thus not redirect the page. Or calling the PageReference method booter() does not do anything.
Below is the controller code i have currently:
Many thanks in advance for any feedback and nudges in the right direction.
I am looking to create a series of pages that allow for creation of multiple custom objects. The first step however before anything can be rendered or created is to check the 'v' parameter in the URL to ensure that the vendor exists.
i keep running into problems when i look to inslude the logic in the controller constructor. It is my understanding from the documentation that the controller constructor will be processed first, then getter, then actions etc...
The below logic either will not compile, because the contrstor cannot return a value, and thus not redirect the page. Or calling the PageReference method booter() does not do anything.
Below is the controller code i have currently:
public class ccController { public List<Vendor__c> vendor; //Redirects PageReference booted = new PageReference ('http://www.google.com'); //controller constructor public ccController() { vendor = [SELECT id, name FROM Vendor__c WHERE id = :ApexPages.currentPage().getParameters().get('v') LIMIT 1]; if (vendor.size() == 1){ //vendor is valid do some stuff }else{ //vendor is not valid, redirect to another page //booted.setRedirect(true); //return booted; booter(); } public PageReference booter() { booted.SetRedirect(true); return booted; } public PageReference save() { return null; } public PageReference nextStep(){ return null; } }
Many thanks in advance for any feedback and nudges in the right direction.
reference: http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_page.htm
All Answers
reference: http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_page.htm
I actually went a slightly different route and put the logic in the "getters" and had the page render dynamically based on those results. Rather than redirect the user to a completely separate page.
But, your response will help out on another project where i need to force a redirect.
Thanks again!