Sample Code:
Visualforce page:
<apex:page controller="sample" sidebar="false" >
<apex:form >
<apex:pageblock >
<apex:pageblockSection id="c" title="Contact Details" >
<apex:pageBlockTable value="{!con}" var="Contact ">
<apex:column value="{!Contact.Name}"/>
</apex:pageBlockTable>
</apex:pageblockSection>
<apex:pageblockSection id="a" title="Account Details" >
<apex:pageBlockTable value="{!acc}" var="account">
<apex:column value="{!account.Name}"/>
</apex:pageBlockTable>
</apex:pageblockSection>
<apex:pageBlockButtons location="bottom" >
<apex:commandButton value="Fetch" reRender="c,a" action="{!fetch}"/>
</apex:pageBlockButtons>
</apex:pageblock>
</apex:form>
</apex:page>
Apex Controller:
public class sample
{
public List<My_Contact__c> con{get;set;}
public List<Account> acc {get;set;}
public void fetch()
{
mem = [SELECT Name FROM My_Contact__c];
acc = [SELECT Name FROM Account];
}
}
Output :
Before Click on fetch :
After click on fetch :
Visualforce page:
<apex:page controller="sample" sidebar="false" >
<apex:form >
<apex:pageblock >
<apex:pageblockSection id="c" title="Contact Details" >
<apex:pageBlockTable value="{!con}" var="Contact ">
<apex:column value="{!Contact.Name}"/>
</apex:pageBlockTable>
</apex:pageblockSection>
<apex:pageblockSection id="a" title="Account Details" >
<apex:pageBlockTable value="{!acc}" var="account">
<apex:column value="{!account.Name}"/>
</apex:pageBlockTable>
</apex:pageblockSection>
<apex:pageBlockButtons location="bottom" >
<apex:commandButton value="Fetch" reRender="c,a" action="{!fetch}"/>
</apex:pageBlockButtons>
</apex:pageblock>
</apex:form>
</apex:page>
Apex Controller:
public class sample
{
public List<My_Contact__c> con{get;set;}
public List<Account> acc {get;set;}
public void fetch()
{
mem = [SELECT Name FROM My_Contact__c];
acc = [SELECT Name FROM Account];
}
}
Output :
Before Click on fetch :
After click on fetch :


No comments:
Post a Comment