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
AnjaneyluAnjaneylu 

Wrapper class error.

Hi this is my wrapper class.
Here i am getting the error like : Unknown property 'WrapperClassProcessSelectedclass.Wrapperclass.name'
please help me.
public class WrapperClassProcessSelectedclass {

   public list<Wrapperclass> Wrapperactlst1 {get; set;}
    public list<account> Selectedaccounts {get; set;}
    
    public WrapperClassProcessSelectedclass (){
            Wrapperactlst1  = new list<Wrapperclass>();
            
            for(account acc : [select id, name, billingcity, phone from account ])
            Wrapperactlst1.add(new wrapperclass(acc));
            
     }
        public void process (){
        Selectedaccounts  = new list<account>();
            for(Wrapperclass wra : Wrapperactlst1 ){
                if(wra.isselected == true)
                Selectedaccounts.add(wra.acc);
            }
        }
    public class Wrapperclass {
        public account acc {get; set;}
        public boolean isselected {get;set;}
        public Wrapperclass(account   a){
            acc =  a;
            isselected = false;
        }
          }
 
}

Thanks and regards,
Anji reddy
Vivek DeshmaneVivek Deshmane
Hi,
I am sure your getting error while savng the visualforce page ?

please try to acces  account name as below.
 
<apex:page>
<Apex:pageblock>
<apex:pageblockTable value="{!Wrapperactlst1}" var="record">
<apex:column headerValue=" Account Name">
<apex:outputText value="{!record.acc.Name}"/> 
</apex:column>
</apex:pageblocktable>
</Apex:pageblock>
</apex:page>



please let me know if this helps you.

Best Regards,
-Vivek
Shrikant BagalShrikant Bagal
Please post your VF Code.
AnjaneyluAnjaneylu
Please chceck this code..
 
<apex:page controller="WrapperClassProcessSelectedclass">
     <apex:form >
         <apex:pageBlock>
             <apex:pageblockButtons>
                     <apex:commandButton value="process Selected Accounts" action="{!Process}" reRender="pbt2"/>
                 </apex:pageblockButtons>
             <apex:pageBlockSection columns="2">
                 
                 <apex:pageBlockTable value="{!Wrapperactlst1}" var="acc">
                     <apex:column>
                         <apex:facet name="Header">
                             <apex:inputCheckbox />
                         </apex:facet>
                         <apex:selectList value="{!acc.isselected}"></apex:selectList>
                     </apex:column>
                     <apex:column value="{!acc.name}" headerValue="Account name"/>
                     <apex:column value="{!acc.phone}" headerValue="Account Phone"/>
                     <apex:column value="{!acc.Billingcity}" headerValue="Account Billingcity"/>
                 </apex:pageBlockTable>
                 <apex:pageBlockTable value="{!Selectedaccounts}" var="b">
                   <apex:column value="{!b.name}" headerValue="Account name"/>
                     <apex:column value="{!b.phone}" headerValue="Account Phone"/>
                     <apex:column value="{!b.Billingcity}" headerValue="Account Billingcity"/>
                 </apex:pageBlockTable>
             </apex:pageBlockSection>
         </apex:pageBlock>  
     </apex:form>
</apex:page>

still i am raising the same error..
Thanks and regards,
Anji reddy
Nitish KumarNitish Kumar
Use this 

<apex:column value="{!acc.acc.name}" headerValue="Account name"/> 
 <apex:column value="{!acc.acc.phone}" headerValue="Account Phone"/>
<apex:column value="{!acc.acc.Billingcity}" headerValue="Account Billingcity"/>
Vivek DeshmaneVivek Deshmane
Hi,
Try below code and let me know.
<apex:page controller="WrapperClassProcessSelectedclass">
     <apex:form >
         <apex:pageBlock>
             <apex:pageblockButtons>
                     <apex:commandButton value="process Selected Accounts" action="{!Process}" reRender="pbt2"/>
                 </apex:pageblockButtons>
             <apex:pageBlockSection columns="2">
                 
                 <apex:pageBlockTable value="{!Wrapperactlst1}" var="acc">
                     <apex:column>
                         <apex:facet name="Header">
                             <apex:inputCheckbox />
                         </apex:facet>
                         <apex:selectList value="{!acc.isselected}"></apex:selectList>
                     </apex:column>
                     <apex:column value="{!acc.acc.name}" headerValue="Account name"/>
                     <apex:column value="{!acc.acc.phone}" headerValue="Account Phone"/>
                     <apex:column value="{!acc.acc.Billingcity}" headerValue="Account Billingcity"/>
                 </apex:pageBlockTable>
                 <apex:pageBlockTable value="{!Selectedaccounts}" var="b">
                   <apex:column value="{!b.name}" headerValue="Account name"/>
                     <apex:column value="{!b.phone}" headerValue="Account Phone"/>
                     <apex:column value="{!b.Billingcity}" headerValue="Account Billingcity"/>
                 </apex:pageBlockTable>
             </apex:pageBlockSection>
         </apex:pageBlock>  
     </apex:form>
</apex:page>

Best Regards,
-Vivek
Amit Chaudhary 8Amit Chaudhary 8
Please check below post for wrapper classes in salesforce. I hope that will help you.
https://developer.salesforce.com/page/Wrapper_Class

http://www.sfdcpoint.com/salesforce/wrapper-class-in-apex/

I hope you are trying below code
<apex:page controller="AccountSelectClassController" sidebar="false">
    <script type="text/javascript">
        function selectAllCheckboxes(obj,receivedInputID){
            var inputCheckBox = document.getElementsByTagName("input");
            for(var i=0; i<inputCheckBox.length; i++){
                if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){
                    inputCheckBox[i].checked = obj.checked;
                }
            }
        }
    </script>
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton value="Show Selected Accounts" action="{!processSelected}" rerender="table2"/>
            </apex:pageBlockButtons>
 
            <apex:pageblockSection title="All Accounts" collapsible="false" columns="2">
 
                <apex:pageBlockTable value="{!wrapAccountList}" var="accWrap" id="table" title="All Accounts">
                    <apex:column >
                        <apex:facet name="header">
                            <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
                        </apex:facet>
                        <apex:inputCheckbox value="{!accWrap.selected}" id="inputId"/>
                    </apex:column>
                    <apex:column value="{!accWrap.acc.Name}" />
                    <apex:column value="{!accWrap.acc.BillingState}" />
                    <apex:column value="{!accWrap.acc.Phone}" />
                </apex:pageBlockTable>
 
                <apex:pageBlockTable value="{!selectedAccounts}" var="c" id="table2" title="Selected Accounts">
                    <apex:column value="{!c.Name}" headerValue="Account Name"/>
                    <apex:column value="{!c.BillingState}" headerValue="Billing State"/>
                    <apex:column value="{!c.Phone}" headerValue="Phone"/>
                </apex:pageBlockTable>
 
            </apex:pageblockSection>
        </apex:pageBlock>
    </apex:form>
 
</apex:page>
 
public class AccountSelectClassController{
 
    //Our collection of the class/wrapper objects wrapAccount
    public List<wrapAccount> wrapAccountList {get; set;}
    public List<Account> selectedAccounts{get;set;}
 
    public AccountSelectClassController(){
        if(wrapAccountList == null) {
            wrapAccountList = new List<wrapAccount>();
            for(Account a: [select Id, Name,BillingState, Website, Phone from Account limit 10]) {
                // As each Account is processed we create a new wrapAccount object and add it to the wrapAccountList
                wrapAccountList.add(new wrapAccount(a));
            }
        }
    }
 
    public void processSelected() {
    selectedAccounts = new List<Account>();
 
        for(wrapAccount wrapAccountObj : wrapAccountList) {
            if(wrapAccountObj.selected == true) {
                selectedAccounts.add(wrapAccountObj.acc);
            }
        }
    }
 
    // This is our wrapper/container class. In this example a wrapper class contains both the standard salesforce object Account and a Boolean value
    public class wrapAccount {
        public Account acc {get; set;}
        public Boolean selected {get; set;}
 
        public wrapAccount(Account a) {
            acc = a;
            selected = false;
        }
    }
}


Please let us know if this will help you

Thanks
Amit Chaudhary
 
AnjaneyluAnjaneylu
<apex:column value="{!acc.acc.name}" headerValue="Account name"/>
<apex:column value="{!acc.acc.phone}" headerValue="Account Phone"/>
<apex:column value="{!acc.acc.Billingcity}" headerValue="Account Billingcity"/>
Here why you have mentioned two times {!acc.acc.name}..
I am unable to know the reason.
Thanks and regards,
Anji reddy
Amit Chaudhary 8Amit Chaudhary 8
first First acc is your Wrapper class object . 2nd Acc is your account object 

WrapperObj.AccountObj.Name
so it is
acc.acc.name