You need to sign in to do that
Don't have an account?
Pat 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>
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>
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
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.
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;
}
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.
public class dataTableLanes {
Public List<Lane_Detail__c> lanes = [SELECT Destination_City__c, Destination_States__c FROM Lane_Detail__c LIMIT 10];
}