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
Suraj DemgundeSuraj Demgunde 

I am Getting unknown property error while accessing the wrapper class member using object.Please suggest me where I am going wrong?

Public Class AccountSelected {
 
    Public List<AccWrap>AccList {get;set;}
   
    Public AccountSelected (){
        List<Account> AccRecords=[Select ID, Name From Account];
         for(Account c:AccRecords){
                 AccList.add(new AccWrap(c));
            }
    }
 
 
    public class AccWrap{
        Public Account Acc;
        Public Boolean CheckBoolean;
       
            Public AccWrap(Account a){
                Acc=a;
                CheckBoolean=false;
            }
    }
}

//////////////////////////

<apex:page controller="AccountSelected ">
 <apex:form>
 <apex:pageBlock>
 
     <apex:pageBlockSection >
         <apex:pageBlockTable value="{!AccList}" var="d">
             <apex:column value="{!d.Acc.name}" />
         </apex:pageBlockTable>
     </apex:pageBlockSection>
 
 </apex:pageBlock>
 
 
 </apex:form>
</apex:page>     
Raj VakatiRaj Vakati
Add get and sets to the wrapper class variables as shown below 
 
Public Class AccountSelected {
 
    Public List<AccWrap>AccList {get;set;}
   
    Public AccountSelected (){
        List<Account> AccRecords=[Select ID, Name From Account];
         for(Account c:AccRecords){
                 AccList.add(new AccWrap(c));
            }
    }
 
 
    public class AccWrap{
        Public Account Acc{get;set;}
        Public Boolean CheckBoolean{get;set;}
       
            Public AccWrap(Account a){
                Acc=a;
                CheckBoolean=false;
            }
    }
}

 
Raj VakatiRaj Vakati
use this code
 
Public Class AccountSelected {
    
    Public List<AccWrap>AccList {get;set;}
    
    Public AccountSelected (){
        AccList =new List<AccWrap>();
        List<Account> AccRecords=[Select ID, Name From Account];
        for(Account c:AccRecords){
            AccList.add(new AccWrap(c));
        }
    }
    
    
    public class AccWrap{
        Public Account Acc{get;set;}
        Public Boolean CheckBoolean{get;set;}
        
        Public AccWrap(Account a){
            Acc=a;
            CheckBoolean=false;
        }
    }
}
 
<apex:page controller="AccountSelected ">
    <apex:form>
        <apex:pageBlock>
            
            <apex:pageBlockSection >
                <apex:pageBlockTable value="{!AccList}" var="d">
                    <apex:column headerValue="Checed??">
                        <apex:inputCheckbox value="{!d.CheckBoolean}" />
                    </apex:column>
                    
                    <apex:column value="{!d.Acc.name}" />
                </apex:pageBlockTable>
            </apex:pageBlockSection>
            
        </apex:pageBlock>
        
        
    </apex:form> 
</apex:page>

 
Ajay K DubediAjay K Dubedi
Hi Suraj,

Please try the below code.

// Apex Class

Public Class AccountSelected {
    
    Public List<AccWrap>AccList {get;set;}
    
    Public AccountSelected (){
        AccList = new List<AccWrap>();
        List<Account> AccRecords=[Select ID, Name From Account limit 5];
        for(Account c:AccRecords){
            AccList.add(new AccWrap(c));
        }
    }
    
    public class AccWrap{
        Public Account Acc{get;set;}
        Public Boolean CheckBoolean{get;set;}
        
        Public AccWrap(Account a){
            Acc=a;
            CheckBoolean=false;
        }
    }
}

// VF Page

<apex:page controller="AccountSelected">
    <apex:form>
        <apex:pageBlock>
            <apex:pageBlockSection >
                <apex:pageBlockTable value="{!AccList}" var="d">
                    <apex:column headerValue="Select Checkbox">
                        <apex:inputCheckbox value="{!d.CheckBoolean}" />
                    </apex:column>
                    <apex:column value="{!d.Acc.name}" />
                </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form> 
</apex:page>

Please select this answer as best if you find it helpful.

Thank You,
Ajay Dubedi