How to reset a visualforce page in Salesforce?

How to reset a visualforce page in Salesforce?

Sample Code:


Visualforce page:


<apex:page controller=”Sample”>
<apex:form >
    <apex:pageBlock >
        <apex:panelGrid >
            Name: <apex:inputtext />
            Age: <apex:inputtext />
            Addres: <apex:inputTextarea />                       
        </apex:panelGrid>
        <apex:pageBlockButtons >
            <apex:commandButton value=”Reset” action=”{!reset}”/>
        </apex:pageBlockButtons>
    </apex:pageBlock>
</apex:form>   
</apex:page>



Apex Controller:


public without Sharing class Sample {
    public Sample() {
    }
    public PageReference reset() {
        PageReference pg = new PageReference(System.currentPageReference().getURL());
        pg.setRedirect(false);
        return pg;
    }
}

Leave a Reply