How to Rerender multiple sections in VisualForce page?

Sample Code:

Visualforce page:

<apex:page controller="sample" sidebar="false" >
<apex:form >
    <apex:pageblock >
        <apex:pageblockSection id="m" title="Member Details" >
            <apex:pageBlockTable value="{!mem}" var="member">
                <apex:column value="{!member.Name}"/>
        <apex:pageblockSection id="a" title="Account Details" >
            <apex:pageBlockTable value="{!acc}" var="account">
                <apex:column value="{!account.Name}"/>
        <apex:pageBlockButtons location="bottom" >
            <apex:commandButton value="Fetch" reRender="m,a" action="{!fetch}"/>

Apex Controller:

public class sample
    public List<Member__c> mem {get;set;}
    public List<Account> acc {get;set;}   
    public void fetch()
        mem = [SELECT Name FROM Member__c];
        acc = [SELECT Name FROM Account];       


Before clicking "Fetch" button:

After clicking "Fetch" button:

No comments:

Post a Comment

Sharing is Caring!!! Share this with your friends!!!

submit to reddit