On a custom VF page (call it page1), I am using apex:commandLink to link to another custom VF page (call it page2) and perform a DML statement. I need to put a series of parameters into the URL as the page I am linking to (page2) uses the parameters to load the appropriate data. Here is my current code:
<apex:commandLink styleClass="button" action="{!saveNextResponse}" value="Save and Continue">
</apex:commandLink>
public String nextQuestionId {get;set;}
public String filter {get; set;}
public String questionBankId {get; set;}
nextQuestionId = '123';
filter = 'all';
questionBankId = '456';
public PageReference saveNextResponse(){
//doing a DML as well
pageRef = new PageReference('/apex/Question');
pageRef.getParameters().put('question',nextQuestionId);
pageRef.getParameters().put('filter',filter);
pageRef.getParameters().put('questionBank',questionBankId);
return pageRef;
}
As I currently have it setup, the DML is working and page2 is loading as expected; however the actual URL itself does not contain the parameters. Instead of being "/Question?question=123&filter=all&questionBank=456", it's just "/Question". What can I do to ensure the parameters are in the URL itself?
pageRef = new PageReference('/apex/Question?question=' + question + '&filter=' + filter + '&questionBank=' + questionBank);