0

I am reading the Visual Force Developer Guide '23 because I have something to do with this technology so I am new. I was reading the section Building a Controller Extension and in the first example I got the followed confusion: enter image description here

The visualForce markup refers to the getGreeting method as greeting.

Could anybody tell me why it is not with the method name? What makes the greeting variable to be referenced to the method getGreeting(). In the case of having two greeting methods like: getGreeting1() and getGreeting2() in this case how would it be referenced in the visualForce markup?

1 Answer 1

2

That's just the convention that Salesforce decided to use.

{!greeting} is calling the getGreeting() method (it's not a variable, nor a property in your controller). For methods that are not "action methods" (relevant documentation here), we can think of it as Salesforce just silently prepending get to the method name.

To answer your example, you would reference them like {!greeting1} and {!greeting2} respectively.

As a final note, the current UI framework that Salesforce is using is Lightning Web Components (LWC for short). Unless you specifically need to work on/support Visualforce, you should be putting time and effort into learning LWC instead.

1
  • Thanks!! I do know a bit of LWC but the problem is that I have to use the Google Maps API so I have to use VF instead of LWC with its lightning-map because of its restrictions Mar 24, 2023 at 7:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .