function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Cameron FinleyCameron Finley 

What controller to use to apex:repeat through all the accounts?

Hello All,
I'm creating a visual force page that needs to contain information from every account in the application.

I tried using the Account standard controller, but I was unable to loop through all the accounts.

Is there a way to loop through (apex:repeat) all the accounts for a salesforce org?
Best Answer chosen by Cameron Finley
Prady01Prady01
hi, The acctLst comes from apex controller which is an extension of VF page.
 
<apex:repeat value="{!acctLst}" var="acc">
<apex:outputText value="{!acc.Name}"/>
</apex:repeat>

Hope this helps!
Prady01

All Answers

Prady01Prady01
hi, The acctLst comes from apex controller which is an extension of VF page.
 
<apex:repeat value="{!acctLst}" var="acc">
<apex:outputText value="{!acc.Name}"/>
</apex:repeat>

Hope this helps!
Prady01
This was selected as the best answer
Cameron FinleyCameron Finley
Hi, what is the name of the controller specifically? Is there a general apex controller that I'm unaware? 
Prady01Prady01
No no there is not standard controller. Since you need to display list of account. Below is the detailed code. There might be some syntax error since I wrote the code directly here.
 
<apex:page controller="FetchAccount">
<apex:form>
<apex:pageBlock>
<apex:repeat value="{!accLst}" var="acc">
<apex:outputText value="{!acc.name}"/>
</apex:repeat>
</apex:pageBlock>
</apex:form>
</apex:page>
 
public with sharing FetchAccount{
public list<Account> accLst{get;set;}

public FetchAccount(){
accLst = New List<Account>();
accLst = [select id, name from Account LIMIT 10];
}
}

Hope this helps!
prady01​​​​​​​