0

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;

        }

    }

}
  • 1
    Please do not remove your code from your posts. This behavior is considered vandalism and if continued, abusive. Once you post your code, it becomes part of the community effort. If you wish to keep it private, then I suggest you refrain from posting it on the internet in the first place. – Adrian Larson May 8 '17 at 15:06
  • @AdrianLarson How is it vandalism if I posted it? – Jargonward May 8 '17 at 17:01
  • As I tried to explain, by posting here you are asking people to contribute to your development effort. If you remove all context from the question once you've gotten what you need out of the community, then you are not contributing to this resource, but rather taxing it for your own needs. There are also licensing issues involved. If you want more detail, you can reach out to the community management team using the contact us link on each page. – Adrian Larson May 8 '17 at 17:05
2

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}
  • wrapChart is not a method it is a class. – Jargonward May 5 '17 at 19:50
  • Then you need to add a property with that type. – Adrian Larson May 5 '17 at 20:09
  • could you show me what the syntax in the context of my code, what your solution look like because I am still getting the same error after making those changes. – Jargonward May 5 '17 at 20:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.