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
Navneeth RajNavneeth Raj 

What's wrong in this Apex Visual Force page & how to write class for this?

<apex:page controller="Person">

        <apex:sectionHeader id="Own_VisualForce" title="Student Twin" subtitle="New Twin Student"
                        description="This is the VisualForce page of Student object"
                        help="/apex/MyVisualForcePage"
                        printUrl="https://c.ap2.visual.force.com/apex/Own?core.apexpages.request.devconsole=1"/>
    <apex:form >
    <apex:pageBlock id="OwnPageblock" title="Student Edit" tabStyle="Opportunity" dir="LTR" helpTitle="Any Help?"
                    helpUrl="https://ap2.salesforce.com/_ui/core/userprofile/UserProfilePage"
                    mode="inline edit" rendered="true" lang="en-IN">
   
        <apex:pageBlockButtons id="Own_pbb" title="PageBlockButtons" dir="LTR" lang="en-US" rendered="true" >
            <apex:commandButton value="Save"/>
            <apex:commandButton value="Save & New"/>
            <apex:commandButton value="cancel" />
            
        <apex:pageBlockSection collapsible="false" columns="4" rendered="true">
            <apex:inputField value="{!Person.Person_Name}"/>
            <apex:inputField value="{!Person.Course}"/>
            <apex:inputField value="{!Student.Country}"/>     

</apex:pageBlockSection>
        </apex:pageBlockButtons>
    </apex:pageBlock>
    </apex:form>
</apex:page>
            User-added image
What's wrong in the above program (ERROR in Line 0 --> Unknown property 'Person.Person') & i'm trying to get the fields of a custom obj named "Person" as shown in the above picture. How to write a class with set & get.
ADITYA PRAKASH 5ADITYA PRAKASH 5
You need to use the full Object API name, which is the same as the name of the standard controller like:

<apex:page standardController="Person__c">
Himanshu ParasharHimanshu Parashar
Hi Naveenth,

We can write a controller for this but why are you not using Standard controller ?
Navneeth RajNavneeth Raj
Ok i'll change. How to  write a class for this using SET & GET
Himanshu ParasharHimanshu Parashar
so if you are using Standard controller there is no need to write GET SET property you can simply write following code
 
<apex:page standardcontroller="Person__c">

        <apex:sectionHeader id="Own_VisualForce" title="Student Twin" subtitle="New Twin Student"
                        description="This is the VisualForce page of Student object"
                        help="/apex/MyVisualForcePage"
                        printUrl="https://c.ap2.visual.force.com/apex/Own?core.apexpages.request.devconsole=1"/>
    <apex:form >
    <apex:pageBlock id="OwnPageblock" title="Student Edit" tabStyle="Opportunity" dir="LTR" helpTitle="Any Help?"
                    helpUrl="https://ap2.salesforce.com/_ui/core/userprofile/UserProfilePage"
                    mode="inline edit" rendered="true" lang="en-IN">
   
        <apex:pageBlockButtons id="Own_pbb" title="PageBlockButtons" dir="LTR" lang="en-US" rendered="true" >
            <apex:commandButton value="Save"/>
            <apex:commandButton value="Save & New"/>
            <apex:commandButton value="cancel" />
            
        <apex:pageBlockSection collapsible="false" columns="4" rendered="true">
            <apex:inputField value="{!Person__c.Person_Name}"/>
            <apex:inputField value="{!Person__c.Course}"/>


</apex:pageBlockSection>
        </apex:pageBlockButtons>
    </apex:pageBlock>
    </apex:form>
</apex:page>




but if you want to learn you can refer following document

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_properties.htm

Thanks,
Himanshu