Activity › Forums › Salesforce® Discussions › How to show my account list on apex page at the time when we preview the page in Salesforce?
-
How to show my account list on apex page at the time when we preview the page in Salesforce?
Posted by shariq on August 17, 2017 at 9:37 AMI want to show my account list at the time when the page loads(At the starting).
shariq replied 7 years, 8 months ago 3 Members · 4 Replies -
4 Replies
-
Hi Shariq,
You can use recordSetVar to view the list and create a variable “var” in <apex:repeat> tag to acess the records. May this example helps you:
<apex:page standardController=”Account” recordSetVar=”Accounts” >
<apex:pageblock>
<apex:repeat var=”a” value=”{!Accounts}” rendered=”true” id=”account_list”>
<li>
<apex:outputLink value=”/{!a.ID}” >
<apex:outputText value=”{!a.Name}”/>
</apex:outputLink>
</li>
</apex:repeat>
</apex:pageblock>
</apex:page> - [adinserter block='9']
-
Hi Neha,
In your apex controller you have taken list in a constructor, I am taking list in a method, then how to show my list when the page loads.
-
You can use recordSetVar and apex:repeat to view the list and variable “var” in <apex:repeat> tag to acess the records.
<apex:repeat value=”{!accs}” var=”acc”>
<tr>
<td><apex:outputText value=”{!acc.Name}”/></td>
<apex:repeat value=”{!acc.Contacts}” var=”cont”>
<td><apex:outputText value=”{!cont.Name}”/></td>
</apex:repeat>
</tr>
</apex:repeat>Thanks
-
Hi Parul,
Correct answer which I got online –
public static List<Account> getListAcc(){
List<Account >accList = new List<Account >();
//Logic
return accList;
}
Then use ListAcc on VF page.
Thanks.
Log In to reply.