How to have multiple custom input checkboxes in the apex - salesforce?
Apex
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, false));
}
}
return chrcs;
}
Public PageReference chk(){
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, false));
}
return null;
}
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, Boolean selected) {
this.chrc = chrc;
this.selectd = false;
}
}
}
Visualforce
<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="{!chrcs}" var="eachpet">
<apex:column value="{!eachpet.chrc.Name}" />
<apex:inputCheckbox value="{!eachpet.selectd}" />
</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>
</apex:page>