[SalesForce] Save and Cancel Button not working

Can any one help me out ?

As per the requirement , i have created a vf page ,i have been using the standard button functionality SAVE and CANCEL .But the problem is the Save and Cancel button does not work.when i give the data click on save it should save the data and when we click on the cancel button it should go back to the previous page where the user was.The button does not work .Any help very much appreciated.

VF Page :

<apex:page standardController="Case"  extensions="MassCloseCasesController" sidebar="false">
  <apex:form >
    <apex:SectionHeader title="Close Cases"/>
      <apex:pageBlock >
        <apex:pageBlockButtons location="Both">
          <apex:commandButton action="{!Save}" value="Save"/>
          <apex:commandButton action="{!Cancel}" value="Cancel" immediate="true"/>
        </apex:pageBlockButtons>
           <apex:pageBlockSection collapsible="false" title="Case Information" >
             <apex:inputField value="{!Case.Status}"/>
             <apex:inputField value="{!Case.Reason_For_Resolution__c}" label="Reason For Resolution"/>
             <apex:inputField value="{!Case.Comment__c}" label="Internal Comments"/>
             <apex:inputField value="{!Case.Do_Not_Send_Email_Case_Closure__c}" label="Do Not Send Email Case Closure"/>
        </apex:pageBlockSection>
      </apex:pageBlock>
  </apex:form>
</apex:page>

Code :

public with sharing class MassCloseCasesController {

    public MassCloseCasesController(ApexPages.StandardController controller) {

    List<Case> cases = [Select ID,CaseNumber From Case where id = :ApexPages.CurrentPage().getparameters().get('id')];

        System.debug('size = '+ cases.size());
    }

        public PageReference save()

    {  


         return null;   


    }
 public PageReference cancel()
    {       

       return null;
}


}

Best Answer

<apex:page standardController="Case"  extensions="MassCloseCasesController" sidebar="false">
      <apex:form >
        <apex:SectionHeader title="Close Cases"/>
          <apex:pageBlock >
            <apex:pageBlockButtons location="Both">
              <apex:commandButton action="{!Save}" value="Save"/>
              <apex:commandButton action="{!Cancel}" value="Cancel" immediate="true"/>
            </apex:pageBlockButtons>
               <apex:pageBlockSection collapsible="false" title="Case Information" >
                 <apex:inputField value="{!objCase.Status}"/>
                 <apex:inputField value="{!objCase.Reason_For_Resolution__c}" label="Reason For Resolution"/>
                 <apex:inputField value="{!objCase.Comment__c}" label="Internal Comments"/>
                 <apex:inputField value="{!objCase.Do_Not_Send_Email_Case_Closure__c}" label="Do Not Send Email Case Closure"/>
            </apex:pageBlockSection>
          </apex:pageBlock>
      </apex:form>
    </apex:page>

Controller:

public with sharing class MassCloseCasesController {

    public Case objCase {get;set;}
    public MassCloseCasesController(ApexPages.StandardController controller) 
    {
        objCase = new Case();
        Id idCase = controller.getId();
        objCase = [SELECT Id, Status, Reason_For_Resolution__c, Comment__c, Do_Not_Send_Email_Case_Closure__c FROM Case WHERE Id : idCase];
    }

    public PageReference save()
    {  
        update objCase;

         return new pagereference('/'+objCase.Id);   


    }
    public PageReference cancel()
    {       
      return new pagereference('/'+objCase.Id);   
    }
}

try with this

Related Topic