You need to sign in to do that
Don't have an account?
Angel30
Getter and Setter methods VF
Hi All,
I am reading through the vf guide however i am not able to visualize the difference between the get;set methods.
i understand that get method will basically fetch data from controller and display in vf page and setter methods are used to pass the values from page to the controller.
i see that there are different ways of writing this.1 is to put logic for each getter and setter method and another method is to just put {get; set;}
Can anybody tell me the difference and how it works .
Thanks a lot!!
I am reading through the vf guide however i am not able to visualize the difference between the get;set methods.
i understand that get method will basically fetch data from controller and display in vf page and setter methods are used to pass the values from page to the controller.
i see that there are different ways of writing this.1 is to put logic for each getter and setter method and another method is to just put {get; set;}
Can anybody tell me the difference and how it works .
Thanks a lot!!
Those two code examples are functionally equivalent. The following code creates a property with a basic getter and setter: The other forms come into play when you want to format or validate data in some way. For example, if you want names to have the first letter uppercase and the rest lowercase: Is there any order of firing the getter and setter method? Is 'setter' method triggers first than 'getter' method?
No, only one or the other is called at a time. Any time you access the property, get is called. Any time you store a value, the set is called.
For more information please check with below links.
- https://salesforce.stackexchange.com/questions/71700/apex-controllers-what-do-the-get-set-do
- http://www.forcetree.com/2009/07/getter-and-setter-methods-what-are-they.html
Hope this helps.Kindly mark this as solved if the reply was helpful.
Thanks,
Nagendra