1

I have a custom page. When I on click save button it does not save anything. Is there anything wrong with my code that I could not find? Thanks

 public PageReference save() {
        if(controller.save() != null) {
        PageReference congratsPage = Page.pitu3;
        congratsPage.setRedirect(true);
        congratsPage.getParameters().put('id',controller.getId());
        return congratsPage;
        }return null;
    }
1
  • 2
    Assuming controller is the StandardController, one reason might be that there is a data validation error on the save. Make sure you have an apex:messages in your Visualforce to see the error output. This is only relevant to the controller.save() returning null path.
    – Keith C
    Commented Jul 2, 2015 at 15:03

1 Answer 1

0

There must be some validation or system error as suggested by Keith. I would suggest to use below to show error to user or at at least use system.debug to see what is going on.

Try{
      if(controller.save() != null) {
           PageReference congratsPage = Page.pitu3;
           congratsPage.setRedirect(true);
           congratsPage.getParameters().put('id',controller.getId());
           return congratsPage;
          }return null;
Catch(Exception e){
   ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage());
   ApexPages.addMessages(myMsg);
   return null;
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .