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
Justin Kitagawa 6Justin Kitagawa 6 

apex:dataTable not seeing object variables

I am trying to build a table that shows leads and contacts... so I created a custom obj class personObject and I am able to instantiate them just fine... 

but when I try to but them into a datatable in visualforce I am running into Error: 'OpportunityExt.personObject.Id'    

Visualforce Page: 
<apex:page standardController="Opportunity" extensions="OpportunityExt"  >

 Raw: {!RelatedPeople}
        <apex:dataTable styleClass="list" width="100%" style="height: 10px;" value="{!RelatedPeople}" var="per">
            <apex:column headerValue="Name" styleClass="dataRow">
                <apex:outputLink value="/per.id" target="_parent">{!per.firstName} {!per.lastName}</apex:outputLink> 
            </apex:column>  
            <apex:column value="{!per.email}" headerValue="Email"/>
            <apex:column value="{!per.Title}" headerValue="Title"/>
            <apex:column value="{!per.Company}" headerValue="Company"/>
            <apex:column value="{!per.Status}" headerValue="Lead Status"/>
        </apex:dataTable>
   

    
    <!-- for soql call -->
<apex:outputField rendered="FALSE" value="{!opportunity.account.website}" />
<apex:outputField rendered="FALSE" value="{!opportunity.account.name}" />

</apex:page>



I can display the raw output just fine: 
[personObject:[Id=0031700000NtXdEAAV, company=McLaren, email=null, firstName=Kevin, lastName=Magnussen, status=Contact Record, title=Chairman and Chief Executive Officer], personObject:[ Id=0031700000NtXRHAA3, company=McLaren, email=ron@mclaren.com, firstName=Ron, lastName=Dennis, status=Contact Record, title=CEO], personObject:Id=0031700000NtXWRAA3, company=McLaren, email=eric@mclaren.com, firstName=Eric, lastName=Boullier, status=Contact Record, title=Racing Director]]




Class: 
public class OpportunityExt {

    private final Opportunity opp;
    
    public OpportunityExt(ApexPages.StandardController stdController) {
        this.opp = (opportunity)stdController.getRecord();
    }
    
    public class personObject {
    // custom constructor
        string firstName; 
        string lastName;
        string email;
        string title;
        string company;
        string Id; 
        string status;
    }    
        

    public List<personObject> getRelatedPeople(){ 
        list<personObject> relatedPeople = new List<personObject>();
        List<Lead> relatedLeads = [SELECT Id, Name, status, email, Title, Company, Website  FROM Lead WHERE  (website = :opp.account.website AND website != null AND isConverted = FALSE)OR (Company LIKE  :opp.account.Name AND isConverted = FALSE)   ORDER BY HG_Focus_User__c DESC, Name ASC LIMIT 1000];
        for(lead ld :relatedLeads){
            personObject person = new personObject();
            person.firstname = ld.firstName;
            person.lastName = ld.lastName;
            person.email = ld.email; 
            person.title = ld.title;
            person.company = ld.company; 
            person.status = ld.status;
            person.Id = ld.id;
            relatedPeople.add(person);
        }
        
        List<Contact> relatedContacts = [SELECT Id, firstName, lastName, email, Title, account.name, account.website, HG_Focus_User__c, HG_Focus_Sign_Up_Date__c FROM Contact WHERE account.id = :opp.account.id];
        for(contact ctc :relatedContacts){
            personObject person = new personObject();
            person.firstname = ctc.firstName;
            person.lastName = ctc.lastName;
            person.email = ctc.email; 
            person.title = ctc.title;
            person.company = ctc.account.name; 
            person.status = 'Contact Record';
            person.Id = ctc.id;
            relatedPeople.add(person);
        }
        
        
        return relatedPeople;
    }

    
}

 
Best Answer chosen by Justin Kitagawa 6
piyush parmarpiyush parmar
Hi,

Please use get set method for your wrapper class variable.
 
public class personObject {
    // custom constructor
        string firstName {get;set;}
        string lastName {get;set;}
        string email {get;set;}
        string title {get;set;}
        string company {get;set;}
        string Id {get;set;}
        string status {get;set;}
    }

 

All Answers

piyush parmarpiyush parmar
Hi,

Please use get set method for your wrapper class variable.
 
public class personObject {
    // custom constructor
        string firstName {get;set;}
        string lastName {get;set;}
        string email {get;set;}
        string title {get;set;}
        string company {get;set;}
        string Id {get;set;}
        string status {get;set;}
    }

 
This was selected as the best answer
Justin Kitagawa 6Justin Kitagawa 6
Thanks! 

I also had to add 'public' to access them .