This is my first time having built a custom controller, and I in a revolving door of errors: This is the code with which I begin, and this DOES work:
apex:
<apex:page controller="AccountCustomController" >
<apex:form >
<apex:pageBlock title="Congratulations {!$User.FirstName}">
<apex:commandButton action="{!savetherecord}" value="Save"/>
</apex:pageBlock>
</apex:form>
</apex:page>
custom controller:
public class AccountCustomController
{
private final Account myaccount;
public PageReference savetherecord()
{
update myaccount;
return null;
}
public String getAccount()
{
update myaccount;
return null;
}
Public AccountCustomController()
{
myaccount = [Select id, Name, Site from Account where id =: ApexPages.currentPage().getParameters().get('id')];
}
}
Then, I add one line to the Apex code, beneath the Congratulations:
<apex:page controller="AccountCustomController" >
<apex:form >
<apex:pageBlock title="Congratulations {!$User.FirstName}">
**You belong to account name: <apex:inputfield value="{!myaccount.name}"/>**
<apex:commandButton action="{!savetherecord}" value="Save"/>
</apex:pageBlock>
</apex:form>
</apex:page>
Then, I get the error: "Error: Unknown property 'AccountCustomController.myaccount'", and it offers to insert the property "AccountCustomController.myaccount" or the method "AccountCustomController.getmyaccount".
I choose "AccountCustomController.myaccount", and get the VisualForce error: "Duplicate field: myaccount".
When I refresh the screen, I get the VisualForce error "System.QueryException: List has no rows for assignment to SObject". At that point, I have to add the inputfield again, and I have come around, once again, to the entrance point of the revolving door. Please help. Thank you.