Custom Controller:
public class mySecondController {
/// Create a list
/// <OBJECT_NAME>
List<TIDev__Project_Requirements__c> rqs;
/// getReq() - Reffer to the list in the
/// visualforce page with "Req" minus the "get" from
/// controller name.
public List<TIDev__Project_Requirements__c> getReq() {
/// Get the data for the list
rqs = [select id, TIDev__Requirement__c, TIDev__Due_Date__c, TIDev__Assigned_to__c from TIDev__Project_Requirements__c Where TIDev__Object__c = 'Account'];
return rqs;
}
}
The custom controller is simply a class with the "get" method invoked. In our example it is called "getReq()". This method quries Salesforce.com for a set of records and returns it to the Visualforce page in a List. The Visualforce page will be able to access this list by referencing the the name of the method minus the "get". So in our example it would be "Req".
Visualforce Page:
<apex:page showHeader="false" sidebar="false" controller='mySecondController'>
<apex:pageBlock title="Requirements" id="tblId">
<apex:dataTable value="{!Req}" var="requirements" cellPadding="4" border="1">
<apex:column>
<apex:facet name="header">Account Requirement</apex:facet>
<apex:outputField value="{!requirements.TIDev__Requirement__c}"/>
</apex:column>
<apex:column>
<apex:facet name="header">Assigned to</apex:facet>
<apex:outputField value="{!requirements.TIDev__Assigned_to__c}"/>
</apex:column>
<apex:column>
<apex:facet name="header">Due Date</apex:facet>
<apex:outputField value="{!requirements.TIDev__Due_Date__c}"/>
</apex:column>
</apex:dataTable>
</apex:pageBlock>
</apex:page>
The first step in your Visualforce page is to link that page to the custom controller you created. This is done with the "controller" tag in the
Next the List is referenced in the
great sample! thanks :D
ReplyDeletebut i just wondering.. what if i want to display 2 table like account and contact on the same row? is it possible on visualforce?
Super example and explanation!
ReplyDeleteThank you!
If all VisualForce tutorial would be explained this way, it would be much, much easier to learn it.
Thank you again!
Super example and explanation!
ReplyDeleteThank you!
If all VisualForce documentation was written this way, it would be much easier to learn VF.
First simple and clear explanation of this topic.
Thank you!
You helped solve 1 week problem.
ReplyDeletemagnificent!