Skip to main content
1. program for getter method using visualforce page and class.

2. program for getter and setter

 
3 respuestas
  1. 22 abr 2019, 07:22
    Hi Himanshu,

    Please follow the given below steps and link with the help of these steps and links you can solve your problem, it may be helpful to you.

    Apex Getter and Setter methods:

    When we want to refer Apex class variables in the visualforce page we need to use Apex getter and setter methods. In this Salesforce tutorial, we will understand about Apex getter method and setter method in detail.

    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.

    public class Example

       {

         public void Set(String name)

           {

             this.name = name;

           }

         public String getName()

           {

             return name;

           }

        }

    -------------------------------------

    get method ( )

    Example : <apex:outputlabel > {!name} </apex:outputlabel>.

    Example for getter method using visualforce and Apex class

    public class Prasanth 

    {

        String name;

        

         public String getName()

         {

             return 'Tutoriart.com';

         }

    }

    Visualforce page:

    <apex:page controller="example2" sidebar="false">

        <apex:outputLabel> {!name}</apex:outputLabel>

    </apex:page>

    For more detail follow this Link:

    https://www.tutorialkart.com/learn_apex/visualforce-getter-method-and-setter-method/

    I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

    Thanks and Regards,

    Deepali Kulshrestha
0/9000