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
Shivani Thakur 32Shivani Thakur 32 

The accounts manager should be able to view a list of all the accounts present in my organization. Develop a VF page for the same. The columns that should be present on the page are: a. Account Name b. Email address c. Phone number d. Website

ANUTEJANUTEJ (Salesforce Developers) 
Hi Shivani,

You can check this below link that has an example of showing account records.

>> https://developer.salesforce.com/forums/?id=906F0000000AxfCIAS
 
Try the below code for your requirement.

Apex Controller : This controller to get the Account id from the page block table when user click it and it will display the list of contacts associated with that particular contact

public with sharing class DisplayContact {
    public List<Contact> conList {get;set;}
    public DisplayContact(ApexPages.StandardSetController controller) {

    }
    
    public PageReference ContactLists()
    {
    if(ApexPages.currentPage().getParameters().get('id') != null)
      conList = [Select id,Name,Phone,Email from contact where accountId =: ApexPages.currentPage().getParameters().get('id')];
     return null;
    }   

}



Visualforce : Visualforce page to display all the acocunt record and its contact record. For the partical page refresh we used rerender concept in the visualforce page
 
<apex:page standardController="Account" recordSetVar="accounts" tabstyle="account" sidebar="false" extensions="DisplayContact" >
  <apex:pageBlock title="Account" >
    <apex:form >
      
      <apex:pageBlockTable value="{!accounts}" var="a" id="list">
      
        <apex:column headerValue="Account Name">
        <apex:commandLink rerender="contactDetails" value=" {!a.Name}" action="{!ContactLists}">
         
         <apex:param name="id" value="{!a.id}"/>
       </apex:commandLink> 
         </apex:column>
        <apex:column value="{!a.type}" />
        <apex:column value="{!a.billingstreet}"/>
        <apex:column value="{!a.billingCity}" />
        <apex:column value="{!a.billingCountry}" />
        <apex:column value="{!a.billingPostalCode}"/>
        <apex:column value="{!a.createdById}"/>
      </apex:pageBlockTable>
     
    </apex:form>
   
  </apex:pageBlock>
  <apex:pageBlock title="Contact">
   <apex:outputPanel id="contactDetails">
     <apex:pageBlockTable value="{!conList}" var="con" id="conlist" title="Contact">
     <apex:column value="{!con.Name}"/>
     <apex:Column value="{!con.Phone}" />
     <apex:Column value="{!con.Email}" />
     </apex:pageBlockTable>
        
  
    </apex:outputPanel>
  </apex:pageBlock>
  
</apex:page>

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.
ANUTEJANUTEJ (Salesforce Developers) 
Do note that the apex class is using with sharing and as mentioned in this documentation : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_keywords_sharing.htm

"Use the with sharing or without sharing keywords on a class to specify whether sharing rules must be enforced. Use the inherited sharing keyword on an Apex class to run the class in the sharing mode of the class that called it."