You need to sign in to do that
Don't have an account?
MnZ321
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:commandLink>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
<apex:outputPanel id="out">
<apex:detail subject="{!$CurrentPage.parameters.id}" relatedList="false" title="false"/>
</apex:outputPanel>
</apex:panelGrid>
</apex:page>
<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:commandLink>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
<apex:outputPanel id="out">
<apex:detail subject="{!$CurrentPage.parameters.id}" relatedList="false" title="false"/>
</apex:outputPanel>
</apex:panelGrid>
</apex:page>
Hi,
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 :)
Regards,
MnZ