function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Divya GoelDivya Goel 

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 + ')';
}
}
 

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>
aballardaballard
I think you're looking at the preview documentation for Spring 08 release.   In the Winter 08 release, this method is called getSubject().
GerhardNewman2GerhardNewman2

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:

Error:
System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Name

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?