This is my first time having built a custom controller, and I can't get past thein a revolving door of errors I'm getting: 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}">
You belong to account name: <apex:inputfield value = "{!myaccount.name}"/>
<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')];
}
}
WithoutThen, I add one line to the following trailer onApex code, beneath the web addressCongratulations: "?id=xxx"
<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 "Could not resolve the entity from apex:inputField value binding '{!account "Error: Unknown property 'AccountCustomController.name}'myaccount'", and it offers to insert the property "AccountCustomController." That muchmyaccount" or the method "AccountCustomController.getmyaccount".
I understandchoose "AccountCustomController.myaccount", and get the VisualForce error: "Duplicate field: myaccount".
When I addrefresh the idscreen, I now get the VisualForce error "Attribute value in apex"System.QueryException:inputfield must contain only a formula expression that resolves List has no rows for assignment to a single controller variable or method in CustomController1"SObject". Since the id field is, by definition, a single value At that point, it should not be complaining about a duplicate value. I can't determineI have to add the thing about which it is complaininginputfield again, and I keep going back and forthhave come around, once again, to the entrance point of the revolving door. Please help. Thank you.