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
Amit Yadav 9Amit Yadav 9 

Unknown property error

i m trying to use a controller on a custom object. Class is compiling fine but my VF page is showing an error as "Unknown property 'MyController.Position__c'"
This is my class
public class MyController 
{
    private final Position__c p {get;set;}
    public MyController() 
    {
        p = [SELECT Id, Name FROM Position__c
                   WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
    }
    
    public PageReference save() 
    {
        update p;
        return null;
     }
}


And this is my VF page

<apex:page controller="MyController" tabStyle="Position__c">
    <apex:form >
        <apex:pageBlock title="Congratulations {!$User.FirstName}">
            You belong to position Name: <apex:inputField value="{!Position__c.Name}"/>
            <apex:commandButton action="{!save}" value="save"/>
        </apex:pageBlock>
    </apex:form>
</apex:page>




Thanks!!
SonamSonam (Salesforce Developers) 
Amit,

If you use Position__c like Position__c.Name, you will have to use the standard controller.You should be using property "p" to save the Position record as it is the attribute defined within the custom controller being used.