+ Start a Discussion
Pat WimsattPat Wimsatt 

My first Visualforce page

I am trying my first attempt at Visualforce pages.  I found a sample online and it works fine, but when I change it to use my custom objects, it fails. Here's what I have and getting an error on the page saying "Unknown property 'dataTableLanes.lanes'.  It clearly exists.  What am I missing?

The Class:
public class dataTableLanes {
    List<Lane_Detail__c> lanes;
 
    public List<Lane_Detail__c> getLaneDetails() {
        if(lanes == null)
            lanes = [SELECT Destination_City__c, Destination_States__c FROM Lane_Detail__c LIMIT 10];
        return lanes;
    }
}


The Page:

<apex:page controller="dataTableLanes" id="thePage">
    <apex:dataTable value="{!lanes}" var="lane" id="theTable"
        rowClasses="odd,even" styleClass="tableClass">
        <apex:facet name="caption">table caption</apex:facet>
        <apex:facet name="header">table header</apex:facet>
        <apex:facet name="footer">table footer</apex:facet>
 
        <apex:column>
            <apex:facet name="header">Name</apex:facet>
            <apex:facet name="footer">column footer</apex:facet>
            <apex:outputText value="{!lane.Destination_City__c}"/>
        </apex:column>
 
        <apex:column>
            <apex:facet name="header">Owner</apex:facet>
            <apex:facet name="footer">column footer</apex:facet>
            <apex:outputText value="{!lane.Destination_States__c}"/>
        </apex:column>
 
    </apex:dataTable>
</apex:page>
Best Answer chosen by Pat Wimsatt
ANUTEJANUTEJ (Salesforce Developers) 
Hi Pat,

Can you try changing this link List<Lane_Detail__c> lanes; to Public List<Lane_Detail__c> lanes{ get; set; } once and let me know if there are any errors.

Thanks.

All Answers

ANUTEJANUTEJ (Salesforce Developers) 
Hi Pat,

Can you try changing this link List<Lane_Detail__c> lanes; to Public List<Lane_Detail__c> lanes{ get; set; } once and let me know if there are any errors.

Thanks.
This was selected as the best answer
Pat WimsattPat Wimsatt
THAT WORKED!! Thanks!.  I didn't get any data, but at least I got past the error message.  LOL.  Next I can figure out why I'm not returning data..
 
CasselJCasselJ
Maybe:
   Public List<Lane_Detail__c> lanes = getLaneDetails();
 
    public List<Lane_Detail__c> getLaneDetails() {
        List<Lane_Detail__c> tLanes = [SELECT Destination_City__c, Destination_States__c FROM Lane_Detail__c LIMIT 10];
        return tLanes;
    }
ANUTEJANUTEJ (Salesforce Developers) 
Great to see the changes worked and I think you can remove  if(lanes == null) statement and everything should work fine.

In case if this came in handy can you please choose this as best answer so that it can be useful to others in the future.

Thanks.
CasselJCasselJ
or remove the call all together;
public class dataTableLanes {
    Public List<Lane_Detail__c> lanes = [SELECT Destination_City__c, Destination_States__c FROM Lane_Detail__c LIMIT 10];
}
swapna sree 3swapna sree 3
 List<Lane_Detail__c> lanes; to Public List<Lane_Detail__c> lanes{ get; set; }