Skip to main content
added 424 characters in body
Source Link

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.

This is my first time having built a custom controller, and I can't get past the errors I'm getting:

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

Without the following trailer on the web address: "?id=xxx", I get the error "Could not resolve the entity from apex:inputField value binding '{!account.name}'." That much I understand.

When I add the id, I now get the error "Attribute value in apex:inputfield must contain only a formula expression that resolves to a single controller variable or method in CustomController1". Since the id field is, by definition, a single value, it should not be complaining about a duplicate value. I can't determine the thing about which it is complaining, and I keep going back and forth. Please help. Thank you.

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.

Source Link

Problems with building a custom controller in Salesforce

This is my first time having built a custom controller, and I can't get past the errors I'm getting:

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

Without the following trailer on the web address: "?id=xxx", I get the error "Could not resolve the entity from apex:inputField value binding '{!account.name}'." That much I understand.

When I add the id, I now get the error "Attribute value in apex:inputfield must contain only a formula expression that resolves to a single controller variable or method in CustomController1". Since the id field is, by definition, a single value, it should not be complaining about a duplicate value. I can't determine the thing about which it is complaining, and I keep going back and forth. Please help. Thank you.