1

I am getting above error.

    public class actionSupportController {
    public List<PCS_Household__c> lstQuery{get;set;} 
    public List<PCS_Household__c> OnlstQuery{get;set;}
    public string ID_c{get;set;}      
    public string test{get;set;}

    public List<wpetwizardcontroller> chrcs{get;set;}
    public List<Characteristics__c> selctchr{get;set;}
    public List<Pets_Information__c> selctpet{get;set;}

    public List<wpetwizardcontroller> getchrc(){
     if(chrcs==null){
       chrcs=new List<wpetwizardcontroller>();
        for(Characteristics__c chrc:[SELECT ID,Good_with_Cats__c,Pet_ID__r.Gender__c,Pet_ID__r.Height__c,Pet_ID__r.Name__c,Pet_ID__r.pet__c,Pet_ID__r.Pet_Photo__c,Pet_ID__r.Status__c FROM Characteristics__c where Good_with_Cats__c=:true]){
          chrcs.add(new wpetwizardcontroller(chrc));
      }
    }
        return chrcs;
    }

    public PageReference incrementCounter() {
       string Query='';
        Query='SELECT ID,Name,Household__c,Phone__c,of_Childrens__c,of_Exiting_Pets__c,Address__c,Previous_Dog__c FROM PCS_Household__c where ID=:test';        
        system.debug('==Query=='+Query);
        OnlstQuery=Database.query(Query);
        system.debug('==lstQuery=='+OnlstQuery);
        return null;
    }

     public Void doSearch(){
        string Query='';
        Query='SELECT ID,Name,Household__c,Phone__c,of_Childrens__c,of_Exiting_Pets__c,Address__c,Previous_Dog__c FROM PCS_Household__c where Household__c LIKE \'%'+ID_c+'%\'';
        system.debug('==Query=='+Query);
        lstQuery=Database.query(Query);
        system.debug('==lstQuery=='+lstQuery);
    }

    public void nullify(){
        lstQuery.clear();
    }

    public PageReference nextpage() {

        upsert OnlstQuery;

        return Page.cc;
    }

      public class wpetwizardcontroller{
        public Characteristics__c chrc{get;set;} 
        public boolean selectd{get;set;}

        public wpetwizardcontroller(Characteristics__c chrc){
            this.chrc=chrc;
            selectd=false;

        }

    }

}


    <apex:page Controller="actionSupportController">
   <apex:form >
       <apex:pageBlock >
            Household Name: <apex:inputText value="{!ID_c}"/>
           </apex:pageBlock>
    <apex:pageBlock title="Characteristics Information">
        <apex:pageBlockTable value="{!chrc}" var="eachchr">
        <apex:inputCheckbox value="{!eachchr.Good_with_Cats__c}"/>Goods with Cats<br/>       
            <apex:inputCheckbox value="{!eachchr.HighNeed__c}"/>High Need<br/>
            <apex:inputCheckbox value="{!eachchr.Non_shedder__c}"/>Non-shedder<br/>
            <apex:inputCheckbox value="{!eachchr.Predatory_Tendencies__c}"/>Predatory Tendencies<br/>
            <apex:inputCheckbox value="{!eachchr.kid_friendly__c}"/>Kid Friendly<br/>
        </apex:pageBlockTable>


       <br/><apex:commandButton value="Search" action="{!getchrc}" rerender="sblck"/>
    </apex:pageBlock>
    <apex:outputPanel id="sblck">
    <apex:pageBlock title="Search Results">
    <apex:pageBlockTable value="{!selctpet}" var="eachpet">
        <apex:column value="{!eachpet.Name}"/>
        <apex:column value="{!eachpet.Gender__c}"/>
        <apex:column value="{!eachpet.Height__c}"/>
        <apex:column value="{!eachpet.Name__c}"/>
        <apex:column value="{!eachpet.pet__c}"/>
        <apex:column value="{!eachpet.Pet_Photo__c}"/>
        <apex:column value="{!eachpet.Status__c}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
    </apex:outputPanel>
       <apex:commandButton value="Request Adoption"/>
   </apex:form>

2

Update your PBT into this

    <apex:pageBlockTable value="{!chrc}" var="eachchr">
            <apex:inputCheckbox value="{!eachchr.chrc.Good_with_Cats__c}"/>Goods with Cats<br/>       
            <apex:inputCheckbox value="{!eachchr.chrc.HighNeed__c}"/>High Need<br/>
            <apex:inputCheckbox value="{!eachchr.chrc.Non_shedder__c}"/>Non-shedder<br/>
            <apex:inputCheckbox value="{!eachchr.chrc.Predatory_Tendencies__c}"/>Predatory Tendencies<br/>
            <apex:inputCheckbox value="{!eachchr.chrc.kid_friendly__c}"/>Kid Friendly<br/>
        </apex:pageBlockTable>

This will solve your problem.

Also give a read to Wrapper Class so help better understand how we will refer the wrapper class variable.

UPDATE

Here is how you will display it correctly

<apex:pageBlockTable value="{!chrc}" var="eachchr">
     <apex:column headervalue="Heading here>
                <apex:inputCheckbox value="{!eachchr.chrc.Good_with_Cats__c}"/>Goods with Cats
    </apex:column> 
    //use same format for all checkboxes.
| improve this answer | |
  • but i want to display the checkbox. if i called the checkbox in pageblocktable means it is not displaying – muralimano May 23 '16 at 8:49
  • then you need to update your PBT code – Tushar Sharma May 23 '16 at 8:52
  • please give some example – muralimano May 23 '16 at 8:54
  • @muralimano check my updated code. – Tushar Sharma May 23 '16 at 8:55
  • i used tushar but i am getting an error <apex:pageBlockTable value="{!chrc}" var="eachchr"> <apex:column headervalue="heading"> <apex:inputCheckbox value="{!eachchr.chrc.Good_with_Cats__c}"/>Goods with Cats </apex:column> <apex:column headervalue="heading"> <apex:inputCheckbox value="{!eachchr.chrc.Good_with_Cats__c}"/>Goods with Cats </apex:column> </apex:pageBlockTable> – muralimano May 23 '16 at 9:08
0

List name in the pageblocktable (value attribute) and accessing wrapper list variables in the page is wrong.

Try this code.

<apex:pageBlockTable value="{!chrcs}" var="eachchr">
    <apex:inputCheckbox value="{!eachchr.chrc.Good_with_Cats__c}"/>Goods with Cats<br/>       
    <apex:inputCheckbox value="{!eachchr.chrc.HighNeed__c}"/>High Need<br/>
    <apex:inputCheckbox value="{!eachchr.chrc.Non_shedder__c}"/>Non-shedder<br/>
    <apex:inputCheckbox value="{!eachchr.chrc.Predatory_Tendencies__c}"/>Predatory Tendencies<br/>
    <apex:inputCheckbox value="{!eachchr.chrc.kid_friendly__c}"/>Kid Friendly<br/>
</apex:pageBlockTable>
| improve this answer | |

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.