+ Start a Discussion

Learning Visualforce bit by bit. I found this code that shows a list of accounts in my org.

The VF that I'm sharing is working perfectly. Can any body explain me how this VF is actually working? That would be great help. Thanks !

<apex:page standardController="account" recordSetVar="accounts" sidebar="false" showHeader="false">
    <apex:panelGrid columns="2">
        <apex:form >
            <apex:pageBlock >
                <apex:pageBlockTable value="{!accounts}" var="a">
                    <apex:column headerValue="Name" >
                        <apex:commandLink value="{!a.name}" reRender="out">
                            <apex:param name="id" value="{!a.id}"/>
        <apex:outputPanel id="out">
            <apex:detail subject="{!$CurrentPage.parameters.id}" relatedList="false" title="false"/>


You are using standardSetController as you specified recordSetVar  attribute on your page.

What this attribute does is that it pulls "Account" records from Account object and stores them in a variable specified by recordSetVar value. In your case it is "accounts". So accounts is List of Accounts - default size of this list is 20.

This list is used in <apex:pageBlockTable> tag.

This tag is used to iterate over collection of records - value attribute is used to point to your collection i.e. your list of accounts.
using var attribute the page retrieves one record at a time from your list and using <apex:column> tag it displays it on page.

You can refer documentation for more about <apex:detail> tag. Hope this explanation helps you in advancing you in your study :)

Thanks @kulkarni. But can I use recordSetVar attribute for custom controllers? If not, then how?