Activity Forums Salesforce® Discussions What is the use of getter strategies and setter techniques in Visualforce Pages in Salesforce?

  • Prachi

    Member
    August 13, 2019 at 6:20 am

    Hi Hariom,

    Getter Methods-
    Getter methods return values from a controller. Every value that is calculated by a controller and displayed in a page must have a corresponding getter method, including any Boolean variables. For example, in the sample page in Building a Custom Controller, the controller includes a getAccount method. This method allows the page markup to reference theaccount member variable in the controller class with {! } notation. The value parameter of the <apex:inputField> tag uses this notation to access the account, and dot notation to display the account's name. Getter methods must always be named getVariable.

    Setter Methods
    Setter methods pass user-specified values from page markup to a controller. Any setter methods in a controller are automatically executed before any action methods.

    Thanks.

     

    • This reply was modified 5 years, 3 months ago by  Prachi.
  • Nikita

    Member
    August 13, 2019 at 6:21 am

    Hi,

    Get (getter) method is used to pass value from controller to VF page while set (setter) is used to set the value back to the controller variable.

  • Saddam

    Member
    August 13, 2019 at 6:22 am

    Hi Hariom

    Setter method : This will take the value from the visualforce page and stores to the Apex variable name.
    getter method : This method will return a value to a visualforce page whenever a name variable is called.

    Visualforce is a markup language that allows you to describe the user interface components that live on your Force.com .Visualforce is the component-based user interface framework for the Force.com platform. The framework includes a tag-based markup language; similar to HTML.Visualforce is used for building various attractive and dynamic applications.Visualforce lives on the server. So any code you write will be generated and run on the server.

     

  • Achintya

    Member
    August 13, 2019 at 8:07 am

    Getter and Setter methods in salesforce are used to pass data from controller to visualforce and vice versa.

    So once we enter some value in text box means through setter method value will be passed from visualforce page to controller ( Apex class) and same can be retrieved back to visualforce page through controller getter method

Log In to reply.

Popular Salesforce Blogs