[SalesForce] Unknown Property with a StandardController

I am having an issue with my standard controller. I have utilized the Salesforce wrapper class suggestions as a framework for this project. Within the project I am supposed to make a pageBlockTable with inputCheckboxes so that users may select a style of business card corresponding to a quantity (100,250,500,1000). In the process of creating the table I have this error:

Unknown property 'Business_Card_Request__cStandardController.selItem'.

I am assuming I am using either the wrong object, or the wrong list as the value for the pageBlockTable. The corresponding visualforce page and controller code will be below. Any help understanding and fixing this error is greatly appreciated.

Page

        <apex:pageBlockSection title="Step 2: Choose your preferred style and order quantity." collapsible="false" columns="1" id="styleAndQuantitySection">
            <script>
            colorPageBlock(document.getElementById("{!$Component.styleAndQuantitySection}"), "#4d6f85");
            </script>
            <apex:outputText value="Please make your selection of style and quantity.
                                    (You may only make ONE selection per request)" style="font-variant:small-caps"></apex:outputText>
            <apex:pageBlockTable value="{!selItem}" var="c" id="priceTable">
                <apex:column headerValue="Order Quantity" value="{!c.wrapperObj.Order_Quantity__c}" id="orderquantity">
                </apex:column>
                <apex:column headerValue="Thermal">
                    <apex:inputCheckbox id="thermal" onchange="enableDisable(this);" value="{!Business_Card_Request__c.Thermal_Checkbox__c}" onclick="document.getElementById('{!$Component.styleAndQuantitySection.thermal}').checked;"/>
                    <apex:outputLabel for="thermal" value="{!c.wrapperObj.Thermal__c}">
                    </apex:outputLabel>
                </apex:column>
                <apex:column headerValue="Engraved">
                    <apex:inputCheckbox id="engraved" onchange="enableDisable(this);"/>
                    <apex:outputLabel for="engraved" value="{!c.wrapperObj.Engraved__c}">
                    </apex:outputLabel>
                </apex:column>
                <apex:column headerValue="Engraved Reorder (no changes)">
                    <apex:inputCheckbox id="engravedreorder" onchange="enableDisable(this);"/>
                    <apex:outputLabel for="engravedreorder" value="{!c.wrapperObj.Engraved_Reorder__c}">
                    </apex:outputLabel>
                </apex:column>
                <apex:column headerValue="Braille">
                    <apex:inputCheckbox id="braille" onchange="enableDisable(this);"/>
                    <apex:outputLabel for="braille" value="{!c.wrapperObj.Braille__c}">
                    </apex:outputLabel>
                </apex:column>
                <apex:column headerValue="Braille Reorder (no changes)">
                    <apex:inputCheckbox id="braillereorder" onchange="enableDisable(this);"/>
                    <apex:outputLabel for="braillereorder" value="{0, !c.wrapperObj.Braille_Reorder__c, ###,###,###,##0.00}">
                    </apex:outputLabel>
                </apex:column>
            </apex:pageBlockTable>   
        </apex:pageBlockSection>

Area in Controller Needing Attention

 public with sharing class wrapchart {

        List <Business_Card_Request_Price__c> selectedItems = new List <Business_Card_Request_Price__c>();

        public void selItem() {

            for (WrapperClass w: wrapperClassList) {

                if (w.selected == true) {

                    selectedItems.add(w.wrapperObj);

                }
            }

            System.debug('***Selected Items are***'+selectedItems);

        }

        List <Business_Card_Request_Price__c> lstChart = new List <Business_Card_Request_Price__c>();

        List <WrapperClass> wrapperClassList = new List <WrapperClass>();

        WrapperClass w;

        public List <WrapperClass> getListWrapper() {

            return wrapperClassList;

        }

        public wrapchart() {

            lstChart = [Select ID, Order_Quantity__c, Thermal__c, Engraved__c, Engraved_Reorder__c, Braille__c, Braille_Reorder__c 
                        From Business_Card_Request_Price__c order
                        By Order_Quantity__c];

            for(Integer i = 0; i < lstChart.size(); i++) {

                w = new WrapperClass(lstChart[i]);

                wrapperClassList.add(w);

            }

        }

    }

    /*Wrapper Class*/
    public class WrapperClass {

        public Business_Card_Request_Price__c wrapperObj {get;set;}

        public Boolean selected {get;set;}

        public WrapperClass (Business_Card_Request_Price__c wrapperProdObj) {

            this.wrapperObj = wrapperProdObj;

            selected = false;

        }

    }

}

Best Answer

I recommend you read through Apex Properties in its entirety to better understand how to expose properties from your extension to the page.

  • If you want to expose a property as a method, use getMyPropertyName(), not myPropertyName().
    • In other words, change the method name from selItem() to getSelItem().
    • Same would go with wrapChart().
  • An alternative to using methods is the { get; set; } method, which I tend to prefer. You can read more about it in the link I posted at the top of this post.
  • You don't have selItem included as a top-level property on your extension. If you expose both of the above as property getter methods instead, then you would need to change your markup from {!selItem} to {!wrapChart.selItem}