You need to sign in to do that
Don't have an account?

Save and Go To New Page
Hey all,
I am trying to figure out how to use a command button that will save a Visualforce Page, then open a new Visualforce page passing in Parameters for the new page to use.
I know that I would use a controller extension on the first page and include the standard save component, but what would I do afterwards? This is the code for the commandbutton itself and the parameters to pass to the new page
<apex:pageBlockButtons > <Apex:commandbutton value="Save and Add Call Attendee" Action="{!save}"><Apex:param name="Account" value="{!Call_Report__c.Account__c}"/><apex:param name="CallReport" value="{!Call_Report__c.Name}"/></apex:commandbutton> </apex:pageBlockButtons>
And this is the save component. How would I open a new page after the save? Is it a simple PageReference call to the new VF page? Is there something much more complicated?
public PageReference save() { PageReference CRsave = controller.save(); //I imagine something else would go here... return CRSave; }
The save method needs to return the URL of the page that you want to redirect to. Lets say the Visualforce page that you want to redirect to is called /apex/nextPage, then the following code can be added to the Visualforce controller extension
public PageReference save()
{
PageReference nextPageURL = new PageReference('/apex/nextPage');
nextPageURL.getParameters().put('parameterName','parameterValue');
return nextPageURL;
}
All Answers
The save method needs to return the URL of the page that you want to redirect to. Lets say the Visualforce page that you want to redirect to is called /apex/nextPage, then the following code can be added to the Visualforce controller extension
public PageReference save()
{
PageReference nextPageURL = new PageReference('/apex/nextPage');
nextPageURL.getParameters().put('parameterName','parameterValue');
return nextPageURL;
}
Thank you for your reply.
I got this far, but for some reason the parameters still aren't passing correctly. I tried hard coding some data to test the pass through, but it's not being received correctly, or so I'm guessing. I'm getting a "Attempt to De-Reference null value" error message.
Here's the parameters being passed through:
And on the Controller of the receiving page:
And in the URL the parameters are there, but it's still giving me a null value error. I even tried to change it to pass through the IDs themselves, but still no luck.
What gives?
I actually got this to work. I had forgotten to instantiate the processes through the standard controller. Silly me.
Thanks again!