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
TechnossusTechnossus 

How to resolve this Error Unknown property 'ExtentionController.objPatient'

Hi,

 

I created the Custom object named by Patient, i want custom page for save the relevant data in this object ...so i create the page controller class as given below

 

public with sharing class ExtentionController
{
Patient__c objPatient = new Patient__c();
Physician__c objPhysician = new Physician__c();
Case_Accession__c objAccession = new Case_Accession__c();

public void save()
{
try
{
Insert objPatient;
Insert objPhysician;
objAccession.Patient__c = objPatient.id;
objAccession.Physician__c = objPhysician.id;
Insert objAccession;
}
catch(Exception ex){ }
}
}

 

VF page

 

<apex:page controller="ExtentionController" >
<apex:form >
<apex:pageblock title="Hello {!$User.FirstName}!" >
<h1>Congratulations</h1>
This is your Accession Page !!<p/>
<apex:pageBlockSection >
<apex:inputText value = "{!objPatient.FirstName__c}"/>
<apex:inputtext value = "{!objPhysician.FirstName__c }"/>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton action="save()" value="Go"/>

<apex:commandButton action="{!cancel}" value="Cancel">
</apex:commandButton>
</apex:pageBlockButtons>
</apex:pageblock>
</apex:form>
</apex:page>

 

 

ryanjuptonryanjupton

You don't have getters and setters for 

Patient__c objPatient = new Patient__c();
Physician__c objPhysician = new Physician__c();
Case_Accession__c objAccession = new Case_Accession__c();

 

 

 

Puja_mfsiPuja_mfsi

Hi,

You need to use get;set; and declare variable as public,if you want to access the class variable in visual force Page.

public with sharing class ExtentionController
{
         public Patient__c objPatient {get;set;} 
         Physician__c objPhysician = new Physician__c();
         Case_Accession__c objAccession = new Case_Accession__c();

       

         public ExtensionController() {

                    objPatient= new Patient__c();

         }

         /*** do other work.***/
}

TechnosTechnos

Thanks for the reply Puja but ,, when I am saving my record

 

java.lang.IllegalArgumentException: Illegal view ID save(). The ID must begin with /

 

this another  error is coming, Any idea

 

Regards

Raman

Puja_mfsiPuja_mfsi

Hi,

 

<apex:commandButton action="save()" value="Go"/>

change it to

<apex:commandButton action="{!save}" value="Go"/>

TechnosTechnos

It worked, You are brilliant

 

Cheers

Raman

Puja_mfsiPuja_mfsi

Hi,

Thanks

Please mark it as a solution ,And if the above post helps you please give Kudos(click on start at left)

TechnosTechnos

Ok, that I will do ,

 

But can explaiin how this is taking the function Save of Controller

 

<apex:commandButton action="{!save}" value="Go"/>

 

Because in Satandard object we write like this only

 

action = save()

Puja_mfsiPuja_mfsi

This is the way to invoke controller method in visual force page.