Checking Accounts Contact – Visual force page to get related Contacts by searching account.

Displaying related contact of an account by entering account name in a text box:This scenario describes the usage of apex:actionstatus. By using apex:actionstatus we can display status message when page is loading. For this we have to use apex:facet along with actionstatus.

Visualforce page:

<apex:page sidebar="false" controller="AccWithAllContactsClass">
<apex:form >
<apex:inputtext value="{!accName}" />
<apex:commandButton value="ShowContacts" action="{!showContacts}" rerender="out" status="mystatus"/><br/>
<apex:actionstatus id="mystatus" starttext="please wait it is loading contacts.......">
<apex:facet name="stop">
<apex:outputpanel id="out">
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockTable value="{!conRecords}" var="c">
<apex:column headerValue="Contacts">


Apex class:

public with sharing class AccWithAllContactsClass {
	List<Account> lstaccount = new List<Account>();
	List<contact> lstcontacts = new List<contact>();
	public List<contact> getConRecords() {
		system.debug('****AccNameTextValue is *****'+accName);
		lstaccount=[select id,name from Account where name=:accName];
		for(Integer i=0;i<lstaccount.size();i++) {
		lstcontacts =[select id,name,accountId from contact where accountid in : accIds];
		system.debug('**** List of Contacts for Test is ***'+lstcontacts);
		return lstcontacts;
	set<string> accIds = new set<string>();
	public pagereference showContacts() {
		return null;
	public String accName { get; set; }


O/P Page:

Checking Accounts