1

enter image description here

VF Page:

<apex:page Controller="actionSupportController">
    <apex:form >
        <apex:pageBlock >
            Household Name: <apex:inputText value="{!ID_c}"/>          
        </apex:pageBlock>
        <apex:pageBlock title="Characteristics Information">
            
            <apex:inputCheckbox value="{!sct.Active__c}" />Active<br/>
            <apex:inputCheckbox value="{!sct.Good_with_Cats__c}" />Good with Cats<br/>
            <apex:inputCheckbox value="{!sct.HighNeed__c}" />HighNeed<br/>
            <apex:inputCheckbox value="{!sct.kid_friendly__c}" />Kid Friendly<br/>
            <apex:inputCheckbox value="{!sct.Non_shedder__c}" />Non Shedder<br/>
            <apex:inputCheckbox value="{!sct.Predatory_Tendencies__c}" />Prediator Tendency<br/>
            
            <br/><apex:commandButton value="Search" action="{!dochar}" rerender="sblck"/>
        </apex:pageBlock>
        <apex:outputPanel id="sblck">
            <apex:pageBlock title="Search Results">
                <apex:pageBlockTable width="80%" value="{!selctchr}" var="eachpe">
                    <apex:column width="80%" value="{!eachpe.Name}"/>
                    <apex:column width="80%" value="{!eachpe.Pet_ID__r.Name__c}"/>
                    <apex:column width="80%" value="{!eachpe.Pet_ID__r.Gender__c}"/>
                    <apex:column width="80%" value="{!eachpe.Pet_ID__r.Height__c}"/>       
                    <apex:column width="80%" value="{!eachpe.Pet_ID__r.pet__c}"/>
                    <apex:column width="80%" value="{!eachpe.Pet_ID__r.Pet_Photo__c}"/>
                    <apex:column width="80%" value="{!eachpe.Pet_ID__r.Status__c}"/>
                </apex:pageBlockTable>
            </apex:pageBlock>
        </apex:outputPanel>
        <apex:commandButton value="Request Adoption"/>
    </apex:form>
</apex:page>

Controller

public class actionSupportController {
    public List<PCS_Household__c> lstQuery{get;set;} 
    public List<PCS_Household__c> OnlstQuery{get;set;}
    public List<Characteristics__c> selctchr{get;set;}
    public Characteristics__c sct{get;set;}
    public string ID_c{get;set;}      
    public string test{get;set;}
   
    public List<Pets_Information__c> selctpet{get;set;}
    
    Public Boolean Good{get;set;}
    

    
    public void dochar(){
        string query='';
        query='SELECT Name,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=:Good';
         system.debug('==query=='+query);
        selctchr=Database.query(query);    
        system.debug('==selctchr=='+selctchr);
    }
  
    
    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('==OnlstQuery=='+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;
    }    
}
1
  • I can't see you are assigning any values to selctchr list
    – Ratan Paul
    Commented May 24, 2016 at 10:26

4 Answers 4

1
<apex:pageBlockTable value="{!selctchr}" var="eachpet">
       <apex:column value="{!eachpet.Name}" />
       <apex:column>
            <apex:inputCheckbox value="{!eachpet.Good_with_Cats__c}" />
       </apex:column>
</apex:pageBlockTable>

Use apex:column to display it properly.

Update use this controller code. As you are not population selctchr

public class actionSupportController {
    public List < PCS_Household__c > lstQuery {get;set;}
    public List < PCS_Household__c > OnlstQuery {get;set;}
    public List < Characteristics__c > selctchr {get;set;}
    public string ID_c {get;set;}
    public string test {get;set;}
    public List < Pets_Information__c > selctpet {get;set;}
    Public Boolean Good {get;set;}

    public actionSupportController ()
    {
          query = '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';
        selctchr  = database.query(query);
    }
    public void dochar() {
        string query = '';
        query = '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';
        Characteristics__c obj = database.query(query);
        Good = obj.Good_with_Cats__c;
    }

    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;
    }
}
8
  • 1
    ahh I was still looking into the code what is issue. you got it
    – Ratan Paul
    Commented May 24, 2016 at 9:18
  • no tushar. checkbox not displaying
    – muralimano
    Commented May 24, 2016 at 9:29
  • @muralimano Did your user have permission of this field? Commented May 24, 2016 at 9:32
  • yes tushar.. i checked permissions are given
    – muralimano
    Commented May 24, 2016 at 9:43
  • @muralimano Please check your updated code and screenshot of the VF page. Commented May 24, 2016 at 9:46
0

Tushar is correct and in addition to this you have to do couple of fixes as below in your code.

1 - In VF page your code is <apex:pageBlockTable value="{!selctchr}" var="eachpet"> but in your controller you are not populating selctchr anywhere. Similarly for this <apex:pageBlockTable value="{!selctpet}" var="eachpet">, selctpet is not updated.

2 - In your command button <apex:commandButton value="Search" action="{!doSearch}" rerender="pblck" /> you are re-rendering the block pblck. But no html element with id pblck is present in your code.

Hope this helps.

6
  • yes saroj. but my goal is i want to display checkbox custom in vf page
    – muralimano
    Commented May 24, 2016 at 9:58
  • my custom object:Characteristics,API-Characteristics__c list of checkboxes Good_with_Cats__c,HighNeed__c,kid_friendly__c,Non_shedder__c,Predatory_Tendencies__c, i want to display these checkbox
    – muralimano
    Commented May 24, 2016 at 10:02
  • please help me.
    – muralimano
    Commented May 24, 2016 at 10:20
  • i have updated my controller with your code. but i am getting an error "Invalid field Gender__c for SObject Characteristics__c"
    – muralimano
    Commented May 24, 2016 at 10:32
  • tushar what mistake i did ?
    – muralimano
    Commented May 24, 2016 at 10:38
0

you haven't put any element in your list that display in datatable i.e. selctchr. First you need to put values in this, may be in constructor then this value shows in Page.

Hope it clear your point.

3
  • if i want to populate the checkbox in pageblock not in data table means.
    – muralimano
    Commented May 24, 2016 at 10:40
  • any comments please
    – muralimano
    Commented May 24, 2016 at 10:51
  • My point is for both pageblock and data table. Commented May 24, 2016 at 10:59
0

@murlimano, first off, we need to check if the user has permission to "Edit" a Characteristics__c record. Even if the user has a "Create" permission and not and "Edit" permission, the user will not be able to see the checkbox as we're "Editing" an existing record (the one we queried in the updated controller). Here are a couple of things you can do:

  1. Check if the user has "Edit" permission in Profile / Permission set
  2. Try loading the same page with another user (System Administrator preferably)
  3. If the other user is able to see the checkbox and the user you're using is not, then you need to check Profile level permissions as well as FLS for the field.

Hope this helps.

Best Regards!

5
  • i cant able to view the tab in the other login but fields are set in full permission.
    – muralimano
    Commented May 24, 2016 at 11:27
  • any one here to correct my program
    – muralimano
    Commented May 24, 2016 at 11:38
  • The tab might not be visible for the other user, please check it on the "All Tabs" page. Also, regarding the code, it seems fine, this is definitely an issue of the permissions on profile level. Try loading the same page using a user having System Administrator profile. Commented May 24, 2016 at 13:13
  • now my checkboxes are visible but the query returning wrongly
    – muralimano
    Commented May 24, 2016 at 14:45
  • hi @muralimano, could you please provide the query and results of the same? Commented May 25, 2016 at 5:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .