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
Javier MaldonadoJavier Maldonado 

I'm getting an error "Unknown constructor 'Dependence.Dependence(ApexPages.StandardController controller)'"

Hellow everyone,

I'm pretty new coding in APEX, so I did this code below to run few fields in a Custom Object combined with a Dependent drop down Pick List, but I'm having a error, described in the subject. I would like to know what my error is, or what I'm doing wrong with this!!! any recommendation I'll appreciate...

APEX CODE
public with sharing class Dependence {
    public string var_Product_Type { get; set; }
    public string var_Product_Name { get; set; }
    
    public Dependence() {
        var_Product_Type = var_Product_Name = null;
        
    }    
          
    public List<SelectOption> getListGroups() {
        List<SelectOption> options = new List<SelectOption> { new SelectOption('','-- Type --') };
        for(Schema.PicklistEntry gr:Product2.Family.getDescribe().getPicklistValues()) {
            options.add(new SelectOption(gr.getValue(),gr.getLabel()));
        }
        return options;
    }
    
    public List<SelectOption> getListProducts() {
        List<SelectOption> options = new List<SelectOption>();
        if(var_Product_Type == null || var_Product_Type == '')
            return options;
        options.add(new SelectOption('','-- Name --'));
        for(Product2 pr:[select id, name from product2 where family = :var_Product_Type]) {
            options.add(new SelectOption(pr.id,pr.name));
        }
        return options;
    }
       
}

VISUALFORCE CODE
<apex:page standardController="Customer_s_Price_List__c" extensions="Dependence">        
    <apex:sectionheader title="{!$ObjectType.Customer_s_Price_List__c.label} Detail" subtitle="{!Customer_s_Price_List__c.Name}"/>
    <chatter:feedwithfollowers entityId="{!Customer_s_Price_List__c.Id}"/>
    <apex:form>
    
        <apex:pageBlock title="Customer's Price List" id="OppPageBlock" mode="edit">
            <apex:pageMessages />                 
                <apex:pageBlockButtons >                 
                    <apex:commandButton value="Save" action="{!save}"/>
                    <apex:commandButton value="Save & New" action="{!saveAndNew}"/>
                    <apex:commandButton value="Cancel" action="{!cancel}"/>                        
                </apex:pageBlockButtons>                                                                                                                         
            
            <apex:actionRegion>
                                                                                                                                    
                    <apex:pageBlockSection title="Customer's Price" columns="1">
                            <apex:inputField value="{!Customer_s_Price_List__c.Account__c}"/>
                            
                            <apex:pageBlockSectionItem >
                                <apex:outputLabel >Product Type</apex:outputLabel>
                                <apex:selectList size="1" multiselect="false" value="{!var_Product_Type}">
                                    <apex:selectOptions value="{!ListGroups}"/>
                                    <apex:actionSupport reRender="theForm" event="onchange"/>
                                </apex:selectList>
                            </apex:pageBlockSectionItem>
                            <apex:pageBlockSectionItem >
                                <apex:outputLabel >Product Name</apex:outputLabel>
                                <apex:selectList value="{!var_Product_Name}" size="1" multiselect="false">
                                    <apex:selectOptions value="{!listProducts}"/>
                                    <apex:actionSupport reRender="theForm" event="onchange"/>
                                </apex:selectList>
                            </apex:pageBlockSectionItem>
                                                                            
                                <apex:outputLabel value="System Of Measurement"/>                         
                                <apex:outputLabel >                             
                                    <apex:inputField value="{!Customer_s_Price_List__c.System_Of_Measurement__c}">                                 
                                        <apex:actionSupport event="onchange" rerender=" OppPageBlock " status="Product Type"/>                           
                                    </apex:inputField>                             
                                    <apex:actionStatus startText="applying value..." id="System_Of_Measurement__c"/>                          
                                </apex:outputLabel>                     
                            
                    </apex:pageBlockSection>                
                        <apex:pageBlockSection title="Imperial System" columns="2" rendered="{!Customer_s_Price_List__c.System_Of_Measurement__c == 'Imperial System'}">                 
                            <apex:inputField value="{!Customer_s_Price_List__c.Wide_Imperial__c}"/>
                            <apex:inputField value="{!Customer_s_Price_List__c.Long_Imperial__c}"/>
                        </apex:pageBlockSection>             
                        <apex:pageBlockSection title="Metric System" columns="2" rendered="{!Customer_s_Price_List__c.System_Of_Measurement__c == 'Metric System'}">                 
                            <apex:inputField value="{!Customer_s_Price_List__c.Wide_Metric__c}"/>
                            <apex:inputField value="{!Customer_s_Price_List__c.Long_Metric__c}"/>             
                    </apex:pageBlockSection>
                               
            </apex:actionRegion>            
        </apex:pageBlock>
    </apex:form>      
</apex:page>
BDatlaBDatla
Hi Javier,

Please udate your constructor to similar to the below code :
 public myControllerExtension(ApexPages.StandardController stdController) { ............. }

Below article will help to better understand controller extension
http://www.salesforce.com/docs/developer/pages/index_Left.htm#CSHID=pages_controller_def.htm|StartTopic=Content%2Fpages_controller_def.htm|SkinName=webhelp

Regards,
BD

 
Javier MaldonadoJavier Maldonado
Hi BD,

Thanks for your reply, but I read that link already this moring, and sorry about this but I'm still lost, I don't know where I have to write, or what I have to write, or what I have to change in my apex code... Can you help me??? Thanks!!!