function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Zeeshan Moulvi 2Zeeshan Moulvi 2 

standard save/cancel button

Hi Team,

I have created a Visualforce Section and added to fields.
When i added Save and cancell button and trying to save/cancel the record the entire page is geting loaded in section.

1. Can anyone help how can add the save and cancell functionality in apex code so only the selected section is refreshed.
2. Once the section is loaded the Inputfields should be like Inline edit instead.

Thanks in Advance. 
Visualforce Page:

<apex:page standardController="Opportunity" extensions="Repack">
    
    
    
<apex:form >
<apex:pageBlock mode="maindetail" id="this">
    
    <div align="center" draggable="false" >
        <apex:commandButton value="Save" action="{!Save}" />
        <apex:commandButton value="Cancel" action="{!Cancel}" reRender="this" />
    </div>
    
        <apex:pageBlockSection columns="2" id="Test" >
              <apex:inputcheckbox value="{!Opportunity.Repack__c}" >
                    <apex:actionSupport event="onchange"  action="{!aaa}" rendered="{!bool}" />
              </apex:inputcheckbox>
                  <apex:inputField value="{!Opportunity.Repack_Class__c}" rendered="{!(Opportunity.Repack__c)}"/>
                  <apex:inputField value="{!Opportunity.Repack_Transition_Phase__c}"  rendered="{!(Opportunity.Repack__c)}"/>
        </apex:pageBlockSection>
   
        <apex:pageBlockSection columns="2" id="Test1" > 
              <apex:inputcheckbox value="{!Opportunity.VPOL__c}" > 
                  <apex:actionSupport event="onchange" action="{!bbb}" rendered="{!bool}" />
              </apex:inputcheckbox>    
        </apex:pageBlockSection>

</apex:pageBlock>
</apex:form>
</apex:page>


Apex Code:
public with sharing class Repack{

    public boolean Repack {get;set;}
    public boolean VPOL{get;set;}
    public boolean bool{get;set;}
    public Opportunity test{get;set;}
    public Opportunity test1{get;set;}

    public Repack(ApexPages.StandardController stdCtrl){   
        this.test=(Opportunity)stdCtrl.getRecord();
        this.test1=(Opportunity)stdCtrl.getRecord(); 
        
        Repack =TRUE;       
        VPOL = TRUE;
        bool = TRUE;
        //this.test=true;//observe the change in this line.Added this for proper behaviour on load 
    }
       
    public pagereference aaa(){
    if(test.Repack__c == true){
        test1.VPOL__c = False;
        bool = TRUE;
    }else{
        bool = FALSE;
    }
    return null;
    }

    public pagereference bbb(){
    if(test1.VPOL__c == true){
        test.Repack__c = false;
        test.Repack_Class__c = Null;
        test.Repack_Transition_Phase__c= Null;
        bool = True;
     }else{
        bool = False;
     }
     return null;
    }
    public PageReference save() {
    return null;
}
   
}

User-added image