+ Start a Discussion

Unknown property when saving VF page with custom controller.

Newbie here. Please be gentle :)


I'm attempting to display (and then edit) a related list.


Error (it says line 0):


Save error: Unknown property 'Bookings_Forecast__cStandardController.lForecasts'


 Custom Controller:


public class ForecastBookingsTest {

String StatusText;
public List<Monthly_Forecast__c> lForecasts;
Boolean InsertFlag;
private final Bookings_Forecast__c BF;

// Constuctor for extending the standard controller
public ForecastBookingsTest(ApexPages.StandardController stdController) {
this.BF = (Bookings_Forecast__c)stdController.getRecord();
StatusText = '';
lForecasts = ForecastList();
InsertFlag = false;

// Fill list with Forecasts
public List<Monthly_Forecast__c> ForecastList(){
List<Monthly_Forecast__c> fl;
try {
fl = [Select c.id, c.Bkgs_Fcst_Amt__c, c.Shippable__c, c.Est_Bkgs_Amt__c, c.Left_to_Book__c, c.Comments__c, c.Date__c
from Monthly_Forecast__c c where c.Bookings_Forecast__c = :BF.id];
} catch (QueryException e){
StatusText = e.getMessage();
return fl;

// Called from Grid to get List of Forecasts
public List<Monthly_Forecast__c> getForecasts () {
if (InsertFlag){
lForecasts.add(new Monthly_Forecast__c(Bookings_Forecast__c = BF.id));
InsertFlag = false;
return lForecasts;

// Called from Page to pass values from grid to controller
public void setForecasts(List<Monthly_Forecast__c> mf) {
lForecasts = mf;

// Called from Page to get StatusText
public String getStatusText() {
return StatusText;

// Called from "Save" Button
public PageReference saveForecasts () {
try {
upsert lForecasts;
} catch (DMLException e) {
StatusText = e.getMessage();
lForecasts = ForecastList();
return null;

// Called from "Add" Button
public PageReference addForecast () {
InsertFlag = true;
return null;




<apex:page standardController="Bookings_Forecast__c" extensions="ForecastBookingsTest" title="Test Bookings Forecast (Lee)" showHeader="true" sidebar="true">
<apex:detail relatedList="false" title="true"/>
<apex:form >
<apex:pageBlock title="Monthly Forecasts" id="gridform">
<apex:pageBlockButtons >
<apex:commandButton action="{!saveForecasts}" value="Save" id="SaveForecastButton" rerender="gridform" status="status"/>
<apex:commandButton action="{!addForecast}" value="New" id="AddForecastButton" rerender="ForecastTable" status="status"/>
<apex:dataTable value="{!lForecasts}" var="item" id="ForecastTable" rowClasses="odd,even" styleClass="" rules="rows" width="100%" columnsWidth="60px">
<apex:column headerValue="Action">
<b><apex:outputLink value="/{!item.id}/e" id="editLink">Edit</apex:outputLink>
<apex:outputLink id="delLink" onclick="if ((Modal.confirm && Modal.confirm('Are you sure?')) || (!Modal.confirm && window.confirm('Are you sure?'))) navigateToUrl('/setup/own/deleteredirect.jsp?delID={!item.Id}&retURL=/apex/ForecastBookingsTest?id={!Forecast_Bookings__c.id}');">Del</apex:outputLink></b>
<apex:column headervalue="Monthly Forecast Name"><apex:outputLink value="/{!item.Id}" target="_self">{!item.name}</apex:outputLink></apex:column>
<apex:column headervalue="Bkgs Fcst Amt" value="{!item.Bkgs_Fcst_Amt__c}"/>
<apex:column value="{!item.Shippable__c}"/>
<apex:column value="{!item.Est_Bkgs_Amt__c}"/>
<apex:column value="{!item.Left_to_Book__c}"/>
<apex:column value="{!item.Comments__c}"/>
<apex:column value="{!item.Date__c}"/>
<apex:actionStatus id="status" startText="Requesting..." stopText="Data Retrieved!"/>&nbsp;{!StatusText}


I'm sure I'm missing something simple.












Best Answer chosen by Admin (Salesforce Developers) 
Your accessor for the list needs to be getLForecasts, not getForecasts.  That should resolve it

All Answers

Your accessor for the list needs to be getLForecasts, not getForecasts.  That should resolve it
This was selected as the best answer

or your dataTable should have a value of {!forecasts} because that's what your getter is called.