You need to sign in to do that
Don't have an account?
Amit 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!!
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!!
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.