You need to sign in to do that
Don't have an account?
Save Button to Redirect user
I'm using this bit of code to allow a save button on a page to save a list, but I'd like the button to redirect the user to a different page after they click Save, much like the Cancel button does now.
public PageReference cancel() { PageReference pr = new PageReference('/a0G/o'); pr.setRedirect(true); return pr; } public void save() { try{ update pfc; } catch(DmlException ex){ ApexPages.addMessages(ex); } }
The save method works, in that what is edited in the list saves, I would just like to add the same PageReference bit from the cancel method to the save method, and I don't know how to do that. :smileyindifferent:
Ideally both cancel and save buttons would direct the user back to the List View from where the visualforce page that uses this class is accessed, but simply redirecting back to the object URL is fine.
Any help would be greatly appreciated!
Same way as u did in cancel button. Just put PageReference code after your save method code,
All Answers
Same way as u did in cancel button. Just put PageReference code after your save method code,
Thank you so much, it works great!
I did have to replace public void save()
with public PageReference save(), as the former was returning an error stating something about a void method returning something or other. :)
Thanks again!
Hi JoeyD,
I got it how to create the method.. Can you tell me what the "update pfc;" will do ?
pfc was my variable for a list of records. The save method updates the changes made to the input fields found between the same form tags on the visualforce page.
Thank You JoeyD.. Good Day..