You need to sign in to do that
Don't have an account?
Ola Bamidele
PageReference is not working
Hi people,
I have this apex code that redirects to another Visualforce page when clicked. When I have 3 PageReferences in the apex, they all work.
However when I have 4 PageReference, they all dont work.
Does anyone know why this is by any chance please?
Thanks you very much!
I have this apex code that redirects to another Visualforce page when clicked. When I have 3 PageReferences in the apex, they all work.
However when I have 4 PageReference, they all dont work.
Does anyone know why this is by any chance please?
public with sharing class CustomerSatisfactionFR2{ public String currentRecordId {get;set;} public CustomerSatisfactionFR2(ApexPages.StandardController controller){ this.currentRecordId = ApexPages.CurrentPage().getparameters().get('id'); } public PageReference UK_Flag () { PageReference pageref = new PageReference('/apex/CustomerSatisfaction_EN?Id='+currentRecordId); pageref.setRedirect(true); return pageref; } public PageReference France_Flag () { PageReference pageref = new PageReference('/apex/CustomerSatisfaction_FR_2?Id='+currentRecordId); pageref.setRedirect(true); return pageref; } public PageReference Dutch_Flag () { PageReference pageref = new PageReference('/apex/CustomerSatisfaction_NL?Id='+currentRecordId); pageref.setRedirect(true); return pageref; } public PageReference Germany_Flag () { PageReference pageref = new PageReference('/apex/CustomerSatisfaction_DE?Id='+currentRecordId); pageref.setRedirect(true); return pageref; } public PageReference Italy_Flag () { PageReference pageref = new PageReference('/apex/CustomerSatisfaction_IT?Id='+currentRecordId); pageref.setRedirect(true); return pageref; } }
Thanks you very much!
As thats what I was thinking, so I am not sure why it is not working - so I was wondering if maybe their is a limit of pagereferences or methods that I could have in this code.
Thanks
I im not 100% sure if I want to change my whole script - especially as im not 100% sure I will be able to adapt mine to the way you sugguested :D.
Also do you think that me changing the code to the way you suggested will make all of the page reference wrk correctly?
Thanks
I understand a bit more now. I've added your code to my apex code however theres one error that I cant overcome.
On line 10, I am getting this error: Do you know why this is?
Thanks very much!
Sorry, the issue is that the "redirect helper" is declared as public PageReference, so it needs to return page reference. My code was more pseudo-code to show you the idea of what I meant, I did not check it for syntax errors such as this.
You can either change it to public void or as Waqar suggested add the return statement return null to the helper method.