First of all I'd say consider renaming your class. For example, you've named your extension account
which can conflict with the Account sObject. I had a simialr problem calling a utility class User
. You can read more about that in my question here with a great answer from Adrian Larson.
Secondly, you're trying to create an <apex:inputField>
referencing an AccountId
which you can't do. Ids are system generated. You can only read them, not write to them.
Because you're using an extension, you'll need to pass in the standard controller as a parameter in the constructor and set it's value to a variable:
public class AccountExtension {
/**
* The variable that stores the Account details
*
* @var Account
*/
private final Account record;
/**
* Contructor. Takes a standard controller variable and assigns it to the record
*
* @param ApexPages.StandardController stdController
*/
public AccountExtension(ApexPages.StandardController stdController) {
this.record = (Account)stdController.getRecord();
}
}
You'll now be able to access fields in your Visualforce Page using typical dot notation.
For example:
<apex:page showHeader="true" sidebar="true" standardController="Account" extensions="AccountExtension">
<apex:form >
<apex:pageBlock id="container" title="Account Form">
<apex:pageBlockButtons>
<apex:commandButton action="{!Save}" value="Save" reRender="errors" status="loading" />
<apex:commandButton action="{!Cancel}" value="Cancel" reRender="errors" status="loading" />
<apex:actionStatus id="loading">
<apex:facet name="start">
<img src="/img/loading.gif" />
</apex:facet>
</apex:actionStatus>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Information">
<apex:inputField value="{!Account.Name}" />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
If you want to access posted values in your extension, you can simply reference the record
variable. For example, if you created a Save()
method that would override the standard Save()
method in your extension:
public PageReference Save() {
String accountName = record.Name;
}
Or, as per your markup you're using a method called changeStatus
:
public PageReference changeStatus() {
String accountName = record.Name;
}