<apex:page standardController="Account" extensions="PickListClass">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection >            
            <apex:commandButton value="Save" action="{!Save}"/><br/>
            <apex:inputText value="{!Account.Name}" />
            <apex:selectList value="{!Rating}" multiselect="false" size="1">
                <apex:selectOptions value="{!RatingOptions}"/>



public class PickListClass{
     public ApexPages.StandardController stdCntrlr {get; set;}
    public void PickListClass(ApexPages.StandardController controller)
        stdCntrlr = controller;

    public String Rating{get; set;}
    public List<String> selectedCategories { get; set; }
    public List<SelectOption> getRatingOptions() {
        List<SelectOption> RatingOptions = new List<SelectOption>();
        RatingOptions.add(new SelectOption('','-None-'));
        RatingOptions.add(new SelectOption('Hot','Hot'));
        RatingOptions.add(new SelectOption('Warm','Warm'));
        RatingOptions.add(new SelectOption('Cold','Cold'));

        return RatingOptions;

  • Have you looked at the documentation on how to create a custom controller to define the constructor? You may also want to think about your naming since there may already be a picklist class for standard visualforce. I know there's a dynamicpicklist class found in the apex docs..
    – crmprogdev
    Oct 3, 2017 at 13:27

1 Answer 1


Constructors do not have a return type.


public class PickListClass{
    public void PickListClass(ApexPages.StandardController controller)
    //     ^^^^
        // not a constructor


public class PickListClass{
    public PickListClass(ApexPages.StandardController controller)
        // now it is a constructor

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .