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
Melissa HowardMelissa Howard 

Visualforce page won't recognize APEX extended controller

I have the following APEX class:

public class ContactExtendedController {
     
       public List<Contact> getContacts() {
            return [SELECT Id, Name, Phone, Email
                FROM Contact
                ORDER BY LastModifiedDate DESC LIMIT 10];
       }
        // Get the 'id' query parameter from the URL of the page.
        // If it's not specified, return an empty contact.
        // Otherwise, issue a SOQL query to return the contact from the
        // database
        
        public Contact getContact() {
        Id id = System.currentPageReference().getParameters().get('id');
        return id == null ? new Contact() : [SELECT Id, Name
            FROM Contact
            WHERE Id = :id];
        }
    
}


And this opening to my VF page errors:

<apex:page standardController="Contact" extensions="ContactExtendedController">

with error: Error: Unknown constructor 'ContactExtendedController.ContactExtendedController(ApexPages.StandardController controller)'


This seems so simple a thing. I can't understand why the "extensions" clause isn't working.

Thanks much,

Evan
Jim JamJim Jam
Try adding a constructor method in your Apex class to include the StandardController... something like ..

public ContactExtendedController(ApexPages.StandardController controller) {

}
Melissa HowardMelissa Howard
Thanks, Constantine. That worked. Do you know anything about getting VF input fields back into APEX, in my case for use in a SELECT query.
Sameer PrasonnSameer Prasonn
Melissa,  in order to recieve VF input field back in to apex. We need to follow some steps described below
1. create some properties eg. public [data-type] [property-name]{get; set;}
2. bind that property with input field e.g <apex:inputfield value={![property-name]}"/>
 once we are done with these step. input field is ready to recieve the value back.

Now you can fire the select query and assign respective field to property and it will populate the field for you. hope this resolve the query.  
Melissa HowardMelissa Howard
Thanks to all who have helped this APEX and VF neophyte. I'm trying to contribute to the forum as I can. OK, so here's the current APEX and VF, which defines 3 properties that need to be bound to 3 input fields on the VF page. I then use those fields for a lookup using the SELECT statement. Then the result of the lookup should be displayed by the input field RequestedBy. Unfortunately, I get the VF error:

Error: Could not resolve the entity from <apex:inputField> value binding '{!lastname}'. <apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable.

public with sharing class ContactExtendedController2 {

    public Contact contactSetting{get;set;}
    public String firstname {get; set;}
    public String lastname {get; set;}
    public String email {get; set;}

    public ContactExtendedController2(ApexPages.StandardController Contact) {
        contactSetting=new Contact();
        contactSetting = [SELECT Id, Name FROM Contact 
            WHERE FirstName = :firstname AND LastName = :lastname AND 
                (Email = :email OR npe01__WorkEmail__c = : email)];
    } 
     
 }

Here is the VF:

<apex:page standardController="Contact" extensions="ContactExtendedController2">
    <apex:form >
        <apex:pageBlock title="Foodbank of Santa Barbara County Volunteer Information">
            <apex:pageBlockSection columns="1">
                <!-- <b>Input Date  :</b><apex:inputfield value="TODAY"/> This gives error, even if value="7/21/2014" -->
                <apex:outputLabel value="Lookup Contact" for="ContactLookup"/>
                <apex:inputField id="RequestedBy" value="{!contactSetting.Name}" />
                
                <apex:inputfield value="{!lastname}"/>
                <apex:inputfield value="{!email}"/>              
                <apex:variable var="firstName" value="{!Contact.FirstName}" />
                <apex:variable var="lastName" value="{!Contact.LastName}" />
                <apex:outputLabel value="Lookup Contact" for="ContactLookup"/>
                <apex:inputField id="RequestedBy" value="{!contactSetting.Name}" />
                <apex:inputField value="{!Contact.Broad_Area_s_You_Want_to_Help_with__c}"/> 
                <apex:inputField value="{!Contact.Other_Broad_Area__c}"/> 
                <apex:inputField value="{!Contact.Ways_You_Would_Like_to_Help__c}"/>                                
                <apex:inputField value="{!Contact.Other_Way_s_You_Would_Help__c}"/>                                                
                <apex:inputField value="{!Contact.Volunteer_Job_Categories__c}"/>                                                
                <apex:inputField value="{!Contact.GW_Volunteers__Volunteer_Availability__c}"/>                 
                <apex:inputField value="{!Contact.Your_Location__c}"/>                                                
                <apex:inputField value="{!Contact.Language_Fluency__c}"/>                                                
                <apex:inputField value="{!Contact.Administrative_Office_Skills__c}"/>  
                <apex:inputField value="{!Contact.IT_Skills__c}"/> 
                <apex:inputField value="{!Contact.Marketing_Design_Skills__c}"/>                 
                <apex:inputField value="{!Contact.Events_Skills_Interests__c}"/>                
                <apex:inputField value="{!Contact.Fundraising_Community_Outreach_Skills__c}"/>                
                <apex:inputField value="{!Contact.Writing_Editing_Skills__c}"/>                
                <apex:inputField value="{!Contact.Leadership_Consultant_Skills__c}"/>                                                                                                                                                                                                           
                <apex:inputField value="{!Contact.Warehouse_Harvesting_Food_Skills__c}"/>                
                <apex:inputField value="{!Contact.Educator_Teaching_Skills__c}"/>                
                <apex:inputField value="{!Contact.Other_Skills__c}"/>                
                <apex:inputField value="{!Contact.Other_Skill__c}"/>                
                <apex:commandButton action="{!save}" value="Update"/>

            </apex:pageBlockSection>
                
        </apex:pageBlock>  
    </apex:form>
    <apex:detail relatedList="false"/>
</apex:page>
Jim JamJim Jam
Change inputfield to inputtext --- Original Message ---
Sameer PrasonnSameer Prasonn
public with sharing class ContactExtendedController2 {
    public Contact contactSetting{get;set;}
    public ContactExtendedController2(ApexPages.StandardController Contact) {
        contactSetting=new Contact();
        contactSetting = [SELECT Id, Name,FirstName,LastName,Broad_Area_s_You_Want_to_Help_with__c,Other_Broad_Area__c , Ways_You_Would_Like_to_Help__c , Other_Way_s_You_Would_Help__c, Volunteer_Job_Categories__c, GW_Volunteers__Volunteer_Availability__c ,Your_Location__c,Language_Fluency__c,Administrative_Office_Skills__c,IT_Skills__c,Marketing_Design_Skills__c,Events_Skills_Interests__c,Fundraising_Community_Outreach_Skills__c,Writing_Editing_Skills__c,Leadership_Consultant_Skills__c,Warehouse_Harvesting_Food_Skills__c,Educator_Teaching_Skills__c,Other_Skills__c  FROM Contact 
           WHERE FirstName = :firstname AND LastName = :lastname AND 
                (Email = :email OR npe01__WorkEmail__c = : email)];

    } 
	public pagereference save(){
		update contactSetting;
	}
}
 
Here is the VF:
<apex:page standardController="Contact" extensions="ContactExtendedController2">

    <apex:form >

        <apex:pageBlock title="Foodbank of Santa Barbara County Volunteer Information">
            <apex:pageBlockSection columns="1">
                <apex:outputLabel value="Lookup Contact" for="ContactLookup"/>
                <apex:inputText id="RequestedBy" value="{!contactSetting.Name}" />
                <apex:inputText value="{!Contact.FirstName}"/>
                <apex:inputText value="{!Contact.LastName}"/>             
                <apex:outputLabel value="Lookup Contact" for="ContactLookup"/>
                <apex:inputText id="RequestedBy" value="{!contactSetting.Name}" />
                <apex:inputText value="{!Contact.Broad_Area_s_You_Want_to_Help_with__c}"/>
                <apex:inputText value="{!Contact.Other_Broad_Area__c}"/>
                <apex:inputText value="{!Contact.Ways_You_Would_Like_to_Help__c}"/>                               
                <apex:inputText  value="{!Contact.Other_Way_s_You_Would_Help__c}"/>                                               
                <apex:inputText value="{!Contact.Volunteer_Job_Categories__c}"/>                                               
                <apex:inputText value="{!Contact.GW_Volunteers__Volunteer_Availability__c}"/>                
                <apex:inputText value="{!Contact.Your_Location__c}"/>                                               
                <apex:inputText value="{!Contact.Language_Fluency__c}"/>                                               
                <apex:inputText value="{!Contact.Administrative_Office_Skills__c}"/> 
                <apex:inputText value="{!Contact.IT_Skills__c}"/>
                <apex:inputText value="{!Contact.Marketing_Design_Skills__c}"/>                
                <apex:inputText value="{!Contact.Events_Skills_Interests__c}"/>               
                <apex:inputText value="{!Contact.Fundraising_Community_Outreach_Skills__c}"/>               
                <apex:inputText value="{!Contact.Writing_Editing_Skills__c}"/>               
                <apex:inputText value="{!Contact.Leadership_Consultant_Skills__c}"/>                                                
                <apex:inputText value="{!Contact.Warehouse_Harvesting_Food_Skills__c}"/>               
                <apex:inputText value="{!Contact.Educator_Teaching_Skills__c}"/>               
                <apex:inputText value="{!Contact.Other_Skills__c}"/>               
                <apex:inputText value="{!Contact.Other_Skill__c}"/>               
                <apex:commandButton action="{!save}" value="Update"/>
            </apex:pageBlockSection>
        </apex:pageBlock> 
    </apex:form>
    <apex:detail relatedList="false"/>
</apex:page>
hope this solution resove your query. 
Evan BurnsEvan Burns
I think so. Thank you so much!
Melissa HowardMelissa Howard
OK, this APEX didn't compile.

Error is "Error: Compile Error: Non-void method might not return a value or might have statement after a return statement. at line 15 column 9"

public with sharing class ContactExtendedController2 {

    public Contact contactSetting{get;set;}
    public String firstname {get; set;}
    public String lastname {get; set;}
    public String email {get; set;}

    public ContactExtendedController2(ApexPages.StandardController Contact) {
        contactSetting=new Contact();
        contactSetting = [SELECT Id, Name FROM Contact
            WHERE FirstName = :firstname AND LastName = :lastname AND
                (Email = :email OR npe01__WorkEmail__c = : email)];
    }
    public pagereference save(){
        update contactSetting;
    }
}

Also, why do we need the last method? This in conjunction with the VF perform a lookup on Contact based on the inputted Email, FirstName and LastName. The updated contact, after all form entries, is saved on the VF page by <apex:commandButton action="{!save}" value="Update"/>.

Sameer PrasonnSameer Prasonn
Mellisa,

first of all i do appologize for the mistake in the code. Please add return null line #11. Since this method is returning pagereference.

we need last method in order to push the updated data back to data store.

and yes, change the SOQL query , add all fields which are required in VF for contact objects. if you don't include, it won't get the data to display. if you are updating the existing data.

hope this resolve the query. 


Sameer PrasonnSameer Prasonn
public pagereference save(){
        update contactSetting;
        return null;
    }

Sameer PrasonnSameer Prasonn
this action is required in order to save the records.
Melissa HowardMelissa Howard
Thanks.

Here is the current APEX. I don't understand what you mean about returning NULL on line 11.

public with sharing class ContactExtendedController2 {

    public Contact contactSetting{get;set;}
    public String firstname {get; set;}
    public String lastname {get; set;}
    public String email {get; set;}

    public ContactExtendedController2(ApexPages.StandardController Contact) {
        contactSetting=new Contact();
        contactSetting = [SELECT Id, Name FROM Contact
            WHERE FirstName = :firstname AND LastName = :lastname AND
                (Email = :email OR npe01__WorkEmail__c = : email)];
    }
    public pagereference save(){
        update contactSetting;
    }
  
 }

Here is the VF. Note the <apex:variable> statements. Those variables are needed by the APEX to do the lookup. Right? They get set after the user inputs Contact.Firstname, .Lastname, and .Email on the form.

<apex:page standardController="Contact" extensions="ContactExtendedController2">

    <apex:form >
        <apex:pageBlock title="Foodbank of Santa Barbara County Volunteer Information">
            <apex:pageBlockSection columns="1">
                <!-- <b>Input Date  :</b><apex:inputfield value="TODAY"/> This gives error, even if value="7/21/2014" -->
                <apex:inputField value="{!Contact.FirstName}"/> 
                <apex:inputField value="{!Contact.LastName}"/> 
                <apex:inputField value="{!Contact.Email}"/> 
                
                <apex:variable var="firstName" value="{!Contact.FirstName}" />
                <apex:variable var="lastName" value="{!Contact.LastName}" />
                <apex:variable var="email" value="{!Contact.Email}" />
                
                <apex:outputLabel value="Lookup Contact" for="ContactLookup"/>
                <apex:inputField id="RequestedBy" value="{!contactSetting.Name}" />         

                <apex:inputField value="{!Contact.Broad_Area_s_You_Want_to_Help_with__c}"/> 
                <apex:inputField value="{!Contact.Other_Broad_Area__c}"/> 
                <apex:inputField value="{!Contact.Ways_You_Would_Like_to_Help__c}"/>                                
                <apex:inputField value="{!Contact.Other_Way_s_You_Would_Help__c}"/>                                                
                <apex:inputField value="{!Contact.Volunteer_Job_Categories__c}"/>                                                
                <apex:inputField value="{!Contact.GW_Volunteers__Volunteer_Availability__c}"/>                 
                <apex:inputField value="{!Contact.Your_Location__c}"/>                                                
                <apex:inputField value="{!Contact.Language_Fluency__c}"/>                                                
                <apex:inputField value="{!Contact.Administrative_Office_Skills__c}"/>  
                <apex:inputField value="{!Contact.IT_Skills__c}"/> 
                <apex:inputField value="{!Contact.Marketing_Design_Skills__c}"/>                 
                <apex:inputField value="{!Contact.Events_Skills_Interests__c}"/>                
                <apex:inputField value="{!Contact.Fundraising_Community_Outreach_Skills__c}"/>                
                <apex:inputField value="{!Contact.Writing_Editing_Skills__c}"/>                
                <apex:inputField value="{!Contact.Leadership_Consultant_Skills__c}"/>                                                                                                                                                                                                           
                <apex:inputField value="{!Contact.Warehouse_Harvesting_Food_Skills__c}"/>                
                <apex:inputField value="{!Contact.Educator_Teaching_Skills__c}"/>                
                <apex:inputField value="{!Contact.Other_Skills__c}"/>                
                <apex:inputField value="{!Contact.Other_Skill__c}"/>                
                <apex:commandButton action="{!save}" value="Update"/>

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

    <!--Offer page without related lists-->
    <apex:detail relatedList="false"/>
</apex:page>
Sameer PrasonnSameer Prasonn
1. since the method is having return type as pagereference. if we are not returning any pagereference ,we must return null or we can return the page reference for the page where we want to redirect the page after updating contact details.

2. one thing which i have noticed. we dont have any Contact object in apex code. change it to contactSetting.
Sameer PrasonnSameer Prasonn
if we are using any lookup the from where it is getting data is not mentioned in apex code. Id must be forworded from other page. correct!!!
Melissa HowardMelissa Howard
I think I must be close. The APEX compiles with a stupid error that I just can't see: Error: Compile Error: expecting right curly bracket, found 'if' at line 15 column 8


Here's the APEX code:

public with sharing class ContactExtendedController2 {

    public Contact contactSetting{get;set;}
    public String firstname {get; set;}
    public String lastname {get; set;}
    public String email {get; set;}

    public ContactExtendedController2(ApexPages.StandardController Contact) {
        contactSetting=new contactSetting();
        contactSetting = [SELECT Id, FirstName, LastName, Email, HomePhone FROM Contact
            WHERE FirstName = :firstname AND LastName = :lastname AND
                (Email = :email OR npe01__WorkEmail__c = : email)];
        }
       
        if (contactSetting == null){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.info,constantClass.'Hello'));
        }    
   
   
    public pagereference save(){
        update contactSetting;
        return null;
    }
    
 }

Thank you so much SMRPRNBRTHSMRPRNBRTH (https://developer.salesforce.com/forums/ForumsProfile?communityId=09aF00000004HMG&userId=005F00000042u2G&showHeader=false" id="ext-gen44), for helping me to finish my first small VF coupled with APEX feature!
Sameer PrasonnSameer Prasonn
Mellissa,

It would be great if you mark the answer as best answer. It would be a good recognization from your side.
Evan BurnsEvan Burns
I tried to do that. But not sure how to. I just hit the thumbs up link on the best answers. Where can I mark an answer the best answer?

Hey, would you mind looking at my last post? I have one last syntax error and I think I will be done.

Thanks!!

Evan
Sameer PrasonnSameer Prasonn
Evan,

Thank you for hitting like for the post. However the person who initiate the post can only choose the "Best Answer". I'll have a look to your post. It would be really great if you can post me a link to your problem.