You need to sign in to do that
Don't have an account?
Why is my VisualForce reference variable working at all?
I have a problem. Or rather, I have a solution that I was expecting to be a problem, and that's bad!
In the code below, after following some tutorial steps for creating a controller extension, I found that I was able to successfully reference a quote from Salesforce CPQ by binding expressions to a variable named "quote". However, I never named a variable "quote" in any of my code, my controller is pointing to a custom object called "EAM_Form__c", and Salesforce CPQ's custom quote object is called SBQQ__Quote__c, rather than just quote. So, I don't understand why I'm able to successfully reference a variable that I never named, for example "{!quote.Voltage__c}".
A snippet of my page:
<apex:page standardController="EAM_Form__c" extensions="EAMFormExtension" showHeader="true"> <apex:form> <apex:pageBlock title="Application Analysis"> <apex:pageBlockSection columns="1"> <apex:inputField value="{!quote.Voltage__c}"/> <apex:inputField value="{!quote.Phase__c}"/> <apex:inputField value="{!quote.Conveyor_Height__c}"/> </apex:pageBlockSection> </apex:pageBlock> <apex:form> </apex:page>
My controller extension:
public class EAMFormExtension { private final EAM_Form__c myForm; // The extension constructor initializes the private member // variable mysObject by using the getRecord method from the standard // controller. public EAMFormExtension(ApexPages.StandardController stdController) { this.myForm = (EAM_Form__c)stdController.getRecord(); } public SBQQ__Quote__c getQuote() { SBQQ__Quote__c myQuote = [Select Id, Name, Voltage__c, Phase__c, Conveyor_Height__c,SBQQ__Opportunity2__c From SBQQ__Quote__c Where Id = :this.myForm.Quote__c Limit 1]; return myQuote; } }
For the sake of learning how this works, can anyone explain this mysterious reference name to me?
All Answers
http://www.forcetree.com/2009/07/getter-and-setter-methods-what-are-they.html
Hi Tuan,
Thanks, this is very informative! I am noticing that in the examples given, they specifically define the variable name "userinput" as a null string before writing the get method, and they use this name in their VisualForce code.
In my example, the only name I apply is "myQuote", yet this does not become the reference name in the visualforce page. I do not instantiate a quote object named "Quote", so I don't know how it knows to pull that name. Do you know where it could be getting this from?
in apex
in VF
in live
Just starting into VisualForce, so this is very helpful to know. Thanks!