You need to sign in to do that
Don't have an account?
Divya Goel
The following Visualforce markup shows how the controller extension from above can be used in a page:
<apex:page standardController="Account" extensions="myControllerExtension">
{!greeting} <p/>
<apex:form>
<apex:inputField value="{!account.name}"/> <p/>
<apex:commandButton value="Save" action="{!save}"/>
</apex:form>
</apex:page>
Code in the VF Guide is giving error
I used following code given in guide for page and extension class. Refer Page 53 on New guide of VF The Error I am getting is :
Method does not exist or incorrect signature: [ApexPages.StandardController].getRecord() at line 7 column 22
public class myControllerExtension {
private final Account acct;
// The extension constructor initializes the private member
// variable acct by using the getRecord method from the standard
// controller.
public myControllerExtension(ApexPages.StandardController stdController) {
this.acct = (Account)stdController.getRecord();
}
public String getGreeting() {
return 'Hello ' + acct.name + ' (' + acct.id + ')';
}
}
private final Account acct;
// The extension constructor initializes the private member
// variable acct by using the getRecord method from the standard
// controller.
public myControllerExtension(ApexPages.StandardController stdController) {
this.acct = (Account)stdController.getRecord();
}
public String getGreeting() {
return 'Hello ' + acct.name + ' (' + acct.id + ')';
}
}
The following Visualforce markup shows how the controller extension from above can be used in a page:
<apex:page standardController="Account" extensions="myControllerExtension">
{!greeting} <p/>
<apex:form>
<apex:inputField value="{!account.name}"/> <p/>
<apex:commandButton value="Save" action="{!save}"/>
</apex:form>
</apex:page>
<SCRIPT type=text/javascript>function initSelectionInEditor() { setSelectionInEditor('Body', 301, 301) }setContentWindow(window);initSelectionInEditor();</SCRIPT>
I am reading the summer 08 guide and it has the same code example as above.
It does not work.
I get an error saying:
I have played witht the example and it does find the acct.id field ok, but none of the other fields (ie acc.name).
How do I reference the other fields?