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
geetha b 8geetha b 8 

Please resolve my problem in wrapper class

Here is mu code

<apex:page controller="testWrapper">
  <!-- Using wrapper class -->
 <apex:form>
   <apex:pageBlockSection>
     <apex:pageBlockTable value="{!books}" var="b">
         <apex:column width = "25px">
                <apex:inputCheckbox value="{!b.checked}" />
            </apex:column>
         <apex:column value="{!b.b1.Name}"/>
        
         <apex:column value="{!b.b1.Price__c}"/>
     </apex:pageBlockTable>
   </apex:pageBlockSection> 
 </apex:form>
 </apex:page>
---------------------------------------------------class--------------------------------------------------
public class testWrapper
{
  public List<Wrapper> books{get; set;}
  public testWrapper()
  {
 
     books = new List<Wrapper>();
     for(Book__c b1 : [select name,Price__c from Book__c])
     {

         books.add(new wrapper(b1));
        
      }
   }  
   public class Wrapper
   {
        public boolean checked {get; set;}
        public Book__c bl {get; set;}
        public Wrapper(Book__c bl)
        {
            this.bl = bl;
            this.checked = false;
        }
    }
 

}
ShashankShashank (Salesforce Developers) 
From what I can infer, you should pass the checkbox too as a boolean to the wrapper class, else it will always be false. Something like this:
 
<apex:page controller="testWrapper">
  <!-- Using wrapper class -->
 <apex:form>
   <apex:pageBlockSection>
     <apex:pageBlockTable value="{!books}" var="b">
         <apex:column width = "25px">
                <apex:inputCheckbox value="{!b.checked}" />
            </apex:column>
         <apex:column value="{!b.b1.Name}"/>
        
         <apex:column value="{!b.b1.Price__c}"/>
     </apex:pageBlockTable>
   </apex:pageBlockSection> 
 </apex:form>
 </apex:page>
---------------------------------------------------class--------------------------------------------------
public class testWrapper
{
  public List<Wrapper> books{get; set;}
  public boolean checked;
  public testWrapper()
  {
 
     books = new List<Wrapper>();
     for(Book__c b1 : [select name,Price__c from Book__c])
     {

         books.add(new wrapper(b1), checked);
        
      }
   }  
   public class Wrapper
   {
        public boolean checked {get; set;}
        public Book__c bl {get; set;}
        public Wrapper(Book__c bl, boolean checked)
        {
            this.bl = bl;
            this.checked = checked;
        }
    }
 

}

 
SarfarajSarfaraj
<apex:page controller="testWrapper">
  <!-- Using wrapper class -->
 <apex:form>
	<apex:pageBlock >
   <apex:pageBlockSection>
     <apex:pageBlockTable value="{!books}" var="b">
         <apex:column width = "25px">
                <apex:inputCheckbox value="{!b.checked}" />
            </apex:column>
         <apex:column value="{!b.bl.Name}"/>
        
         <apex:column value="{!b.bl.Price__c}"/>
     </apex:pageBlockTable>
   </apex:pageBlockSection> 
   </apex:pageBlock>
 </apex:form>
 </apex:page>
geetha b 8geetha b 8
shashank
                    still it is showing the error Error: Unknown property 'testWrapper.Wrapper.b1'
 
ShashankShashank (Salesforce Developers) 
Try this:
 
public class testWrapper
{
  public List<Wrapper> books{get; set;}
  public boolean checked;
  public testWrapper()
  {
 
     books = new List<Wrapper>();
     for(Book__c b1 : [select name,Price__c from Book__c])
     {

         books.add(new wrapper(b1, checked));
        
      }
   }  
   public class Wrapper
   {
        public boolean checked {get; set;}
        public Book__c bl {get; set;}
        public Wrapper(Book__c bl, boolean checked)
        {
            this.bl = bl;
            this.checked = checked;
        }
    }
 

}

 
geetha b 8geetha b 8
with the same code i am geting error shashank.
 
Naveen Rahul 3Naveen Rahul 3
can you post the error pls
geetha b 8geetha b 8
i got it

thank you guys
Monish Mahalingam 13Monish Mahalingam 13
Hai you implementation of Wrapper class is correct but in your VF page code you have refered the wrong variable name. Because in controller you have used bl but in vf you have used b1 (b number 1).
Replace it with bl.