+ Start a Discussion
EliHEliH 

Visualforce page not showing expected results from Controller Extension

I can't figure out why the list of events expected is not showing up on this page. 

VF Page:

<apex:page standardController="Business_Plan__c" extensions="BusinessPlanEventsControllerExtension"> 
<apex:form >
<apex:pageBlock title="Events">
   <apex:pageBlockTable value="{!eventList}" var="oe">
      <apex:column value="{!oe.OwnerId}"/>      
      <apex:column value="{!oe.StartDateTime}"/> 
      <apex:column value="{!oe.EndDateTime}"/>   
      <apex:column >
          <apex:outputField value="{!oe.Subject}" id="Subject" /> 
          <apex:facet name="header">Subject</apex:facet>
      </apex:column>
      <apex:column value="{!oe.Description}">
          <apex:facet name="header">Purpose of Meeting</apex:facet>
      </apex:column>
      <apex:column value="{!oe.Outcome__c}">
          <apex:facet name="header">Desired and Actual Outcome</apex:facet>
      </apex:column>         
   </apex:pageBlockTable>
   
   <apex:pageBlockButtons > 
                <apex:commandButton value="Save" action="{!save}" id="saveButton" />
                <apex:commandButton value="Cancel" action="{!cancel}" id="cancelButton" />
   </apex:pageBlockButtons> 
   
</apex:pageBlock>
</apex:form>
</apex:page>

Controller Extension:

public with sharing class BusinessPlanEventsControllerExtension {
    public Business_Plan__c bp;
    public Business_Plan__c bpInfo;
    public List<Event> eventList {get;set;}
    public List<Task> taskList;
        
    public BusinessPlanEventsControllerExtension(ApexPages.StandardController Controller) {        
        bp = (Business_Plan__c)controller.getRecord();     
    }    

    public List<Event> getEvents(){          
        bpInfo = [SELECT Id FROM Business_Plan__c WHERE id =: bp.Id];
        eventList = new List<Event>();
        eventList = [SELECT Id, OwnerId, Subject, StartDateTime, EndDateTime, Description, Outcome__c,  Complete__c 
                     FROM Event WHERE WhatId =: bpInfo.Id ];
        System.debug('Event List' + eventList);
        return eventList;         
    }                               

}
Best Answer chosen by EliH
Akshay_DhimanAkshay_Dhiman
Hi Elih,

replace your controller code with following code  
 
Controller Extension:
 
public with sharing class BusinessPlanEventsControllerExtension {
    public Business_Plan__c bp;
    public Business_Plan__c bpInfo;
    public List<Event> eventList {get;set;}
    public List<Task> taskList;
        
    public BusinessPlanEventsControllerExtension(ApexPages.StandardController Controller) {        
        bp = (Business_Plan__c)controller.getRecord();
  eventList = new List<Event>();
  eventList = [SELECT Id, OwnerId, Subject, StartDateTime, EndDateTime, Description, Outcome__c,  Complete__c 
                     FROM Event WHERE WhatId =: bp.Id];
  
    }    

}



if you found this answer helpful then please mark it as best answer so it can help others.   
  
  Thanks 
  Akshay

All Answers

Steven NsubugaSteven Nsubuga
<apex:page standardController="Business_Plan__c" extensions="BusinessPlanEventsControllerExtension"> 
<apex:form >
<apex:pageBlock title="Events">
   <apex:pageBlockTable value="{!Events}" var="oe">
      <apex:column value="{!oe.OwnerId}"/>      
      <apex:column value="{!oe.StartDateTime}"/> 
      <apex:column value="{!oe.EndDateTime}"/>   
      <apex:column >
          <apex:outputField value="{!oe.Subject}" id="Subject" /> 
          <apex:facet name="header">Subject</apex:facet>
      </apex:column>
      <apex:column value="{!oe.Description}">
          <apex:facet name="header">Purpose of Meeting</apex:facet>
      </apex:column>
      <apex:column value="{!oe.Outcome__c}">
          <apex:facet name="header">Desired and Actual Outcome</apex:facet>
      </apex:column>         
   </apex:pageBlockTable>
   
   <apex:pageBlockButtons > 
                <apex:commandButton value="Save" action="{!save}" id="saveButton" />
                <apex:commandButton value="Cancel" action="{!cancel}" id="cancelButton" />
   </apex:pageBlockButtons> 
   
</apex:pageBlock>
</apex:form>
</apex:page>

 
Akshay_DhimanAkshay_Dhiman
Hi Elih,

replace your controller code with following code  
 
Controller Extension:
 
public with sharing class BusinessPlanEventsControllerExtension {
    public Business_Plan__c bp;
    public Business_Plan__c bpInfo;
    public List<Event> eventList {get;set;}
    public List<Task> taskList;
        
    public BusinessPlanEventsControllerExtension(ApexPages.StandardController Controller) {        
        bp = (Business_Plan__c)controller.getRecord();
  eventList = new List<Event>();
  eventList = [SELECT Id, OwnerId, Subject, StartDateTime, EndDateTime, Description, Outcome__c,  Complete__c 
                     FROM Event WHERE WhatId =: bp.Id];
  
    }    

}



if you found this answer helpful then please mark it as best answer so it can help others.   
  
  Thanks 
  Akshay
This was selected as the best answer