This basic controller below should work. I get the Content cannot be displayed: Attempt to de-reference a null object. Controller and Visualforce Issue error on the Visualforce page. Looks like my Spend__c is somehow empty.
Controller:
public class StatController {
public Date lastMonthEndDate{get;set;}
public String CompanyID{get;set;}
public StatController(ApexPages.standardController Controller){
getData(); }
public void getData(){
//ApexPages get Id appears to be the issue.
//I have used the exact style shown below for several Visualforce charts with no issues.
Spend__c calcRecord =[SELECT Id, MonthEnd__c, CompanyID__c,
FROM Spend__c
WHERE Account__c = :ApexPages.currentPage().getParameters().get('id')
ORDER BY MonthEnd__c
DESC
LIMIT 1];
Date lastMonthEndDate = calcRecord.MonthEnd__c;
String CompanyID = calcRecord.CompanyID__c;
}
Visualforce:
<apex:page standardController="Account" extensions="StatController">
<apex:outputText label="TEST: " value="{!lastMonthEndDate}"/>
</apex:page>
FIGURED IT OUT! I had code not shown here with "+=". That was causing the de-referencing issue. Took about 6 hours to figure it out :/