I have created a Wrapper class to present data from different objects Event__c
and Campaign
. The class works fine when I hardcode the values for the SOQL statements but when I assign the dynamic values retrieved form a visual force page the table is empty. selectedCampaignValue
and selectedEventValue
are values retrieved from pick lists.
Wrapper Controller
public with sharing class WrapperClassExtension {
public String selectedCampaignValue {get; set;}
public String selectedEventValue {get; set; }
public List<WrapList> countList {get; set;}
public WrapperClassExtension(ApexPages.StandardController controller) {
}
public List<WrapList> getCounts(){
countList = new List<WrapList>();
for(Campaign c : [SELECT id,Name,isActive,NumberOfContacts FROM Campaign WHERE Name LIKE :selectedCampaignValue AND IsActive = True LIMIT 1]){
for(Event__c ev : [SELECT id,Event_Id__c,Event_Name__c,Event_Attendees_Count__c FROM Event__c WHERE Event_Name__c LIKE :selectedEventValue LIMIT 1]){
/*Create a new wrapper and add it to list*/
countList.add(new WrapList(c,ev));
}
}
return countList;
}
public class WrapList {
public Campaign cCount { get; set; }
public Event__c evCount { get; set; }
public WrapList(Campaign c, Event__c ev) {
this.cCount = c;
this.evCount = ev;
}
}
}
Visualforce
<apex:pageBlock id="results_count" title="Count" rendered="{!attending != null}">
<apex:pageMessages />
<apex:pageBlockSection title="DelegateManager Total - {!selectedEventValue}" columns="1" collapsible="true">
<apex:outputText style="font-style:italic"
value="Delegates attending the specified event are listed below. Click the 'Sync All' button to synchronize your Salesforce records with DelegateManager delegates. If you wish to receive an email with a csv file containing failed syncs for the event then press 'Email Csv'."></apex:outputText>
<apex:pageBlockTable value="{!Counts}" var="c" rows="1">
<apex:column headerValue="DelegateManager Total" style="width:30px;">
<apex:outputText value="{!c.evCount.Event_Attendees_Count__c}"/>
</apex:column>
<apex:column headerValue="Campaign Members Total" style="width:75px;">
<apex:outputText value="{!c.cCount.NumberOfContacts}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>