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
krishna guptakrishna gupta 

Getting error "Unknown property 'AccountStandardController.selectedOptions'"

Hi,

I have two visualforce page and one custom controller, but i am getting the error "Unknown property 'AccountStandardController.selectedOptions'".
My controller name : DynamicCustomizableListHandler
visualforce page1 : DynamicCustomizableList
visualforce page 2 : CustomizeDynamicList
public class DynamicCustomizableListHandler {

    private ApexPages.StandardSetController controller;
    private PageReference savePage;
    
    private Set<String> unSelectedNames = new Set<String>();
    private Set<String> selectedNames = new Set<String>();
    private Set<String> inaccessibleNames = new Set<String>();
    
    public 	DynamicCustomizableListHandler(ApexPages.StandardSetController controller){
        this.controller = controller;
        loadFieldsWithVisibility();
    }
    
    private void loadFieldsWithVisibility(){
        Map<String, Schema.SObjectField> fields = Schema.SObjectType.Account.fields.getMap();
        for(String s : fields.keySet()){
            if(s != 'Name'){
                unSelectedNames.add(s);
            }
            if(!fields.get(s).getDescribe().isAccessible()){
                inaccessibleNames.add(s);
            }
        }
    }
    
    public List<String> getDisplayFields(){
        List<String> displayFields = new List<String>(selectedNames);
        displayFields.sort();
        return displayFields;
    }
    
    public PageReference customize(){
        savePage = ApexPages.currentPage();
        return Page.CustomizeDynamicList;
    }
    
    public PageReference show(){
        controller.reset();
        controller.addFields(getDisplayFields());
        return savePage;
    }
    
    public List<SelectOption> getSelectedOption(){
        return selectOptionsFromSet(selectedNames);
    }
    
    public List<SelectOption> getUnSelectedOptions(){
        return selectOptionsFromSet(unSelectedNames);
    }
    
    private List<SelectOption> selectOptionsFromSet(Set<String> opts){
        List<String> optionsList = new List<String>(opts);
        optionsList.sort();
        List<SelectOption> options = new List<SelectOption>();
        for(String s : optionsList){
            options.add(new SelectOption(s, decorateName(s), inaccessibleNames.contains(s)));
        }
        return options;
    }
    
    private String decorateName(String s){
        return inaccessibleNames.contains(s) ? '*' + s : s;
    }
    
    public transient List<String> selected {get; set;}
    public transient List<String> unselected {get; set;}
    
    public void doAdd(){
        moveFields(selected, selectedNames, unSelectedNames);
    }
    
    public void doRemove(){
        moveFields(unselected, unSelectedNames, selectedNames);
    }
    
    private void moveFields(List<String> items, Set<String> moveTo, Set<String> removeFrom){
        for(String s : items){
            if(! inaccessibleNames.contains(s)) {
                moveTo.add(s);
                removeFrom.remove(s);
            }
        }
    }
}
 
<apex:page standardController="Account" recordSetVar="accountList" extensions="DynamicCustomizableListHandler" >
    <br/>
    <apex:form>
    	<apex:pageBlock>
            <apex:outputLabel value="Select Accounts View: " for="viewsList" />
            <apex:selectList id="viewsList" size="1" value="{!filterId}">
                <apex:actionSupport event="onchange" reRender="theTable" />
                <apex:selectOptions value="{!listViewOptions}" />
            </apex:selectList>
        </apex:pageBlock>
        <apex:pageBlock title="Accounts" mode="edit">
            <apex:pageMessages />
            <apex:panelGroup id="theTable">
                <apex:pageBlockTable value="{!accountList}" var="acct">
                    <apex:column value="{!acct.Name}" />
                    <apex:repeat value="{!displayFields}" var="f">
                        <apex:column value="{!acct[f]}" />
                    </apex:repeat>
                </apex:pageBlockTable>
            </apex:panelGroup>
        </apex:pageBlock>
        <br/>
        <apex:commandButton value="Customize List" action="{!customize}" />
    </apex:form>
</apex:page>
 
<apex:page standardController="Account" recordSetVar="ignored" extensions="DynamicCustomizableListHandler">
    <br/>
    <apex:form>
    	<apex:pageBlock title="Select Fields to Display" id="selectionBlock">
            <apex:pageMessages />
            <apex:panelGrid columns="3">
            	<apex:selectList id="unselected_list" required="false" value="{!selected}" multiselect="true" size="20" style="width:250px" >
                    <apex:selectOptions value="{!unSelectedOptions}" />
                </apex:selectList>
                <apex:panelGroup>
                	<apex:commandButton value=">>" action="{!doAdd}" reRender="selectionBlock" />
                    <br/>
                    <apex:commandButton value="<<" action="{!doRemove}" reRender="selectionBlock" />
                </apex:panelGroup>
                <apex:selectList id="selected_list" required="false" value="{!unselected}" multiselect="true" size="20" style="width:250px">
                    <apex:selectOptions value="{!selectedOptions}" />
                </apex:selectList>
            </apex:panelGrid>
            <em> Note: Fields marked <strong>*</strong> are inaccessible to your account</em>
        </apex:pageBlock>
        <br/>
        <apex:commandButton value="Show These Fields" action="{!show}" />
    </apex:form>
</apex:page>
Best Answer chosen by krishna gupta
BALAJI CHBALAJI CH
Hi Krishna Gupta,

At line 44 in your Controller, you have named the get method as "getSelectedOption()", change it to "getSelectedOptions()" (plural) to solve the error.

User-added image

Please let me knoe if that helps you.

Best Regards,
BALAJI

All Answers

BALAJI CHBALAJI CH
Hi Krishna Gupta,

At line 44 in your Controller, you have named the get method as "getSelectedOption()", change it to "getSelectedOptions()" (plural) to solve the error.

User-added image

Please let me knoe if that helps you.

Best Regards,
BALAJI
This was selected as the best answer
krishna guptakrishna gupta
Thankyou BALAJI!