Ads

Friday, 3 May 2013

Hide and show multiple pageBlocks in Salesforce?

Visualforce page:

<apex:page controller="sample">
   
    <apex:form >
   
    <apex:pageBlock >
        <apex:commandButton value="A Section" action="{!callA}"/>
        <apex:commandButton value="B Section" action="{!callB}"/>
    </apex:pageBlock>
   
    <apex:pageBlock rendered="{!Abool}">
       <apex:outputText value="This is A section"/>
    </apex:pageBlock>   
   
    <apex:pageBlock rendered="{!Bbool}">
       <apex:outputText value="This is B section"/>
    </apex:pageBlock>     

    </apex:form>

</apex:page>


Apex Class:

public class sample
{
    public Boolean Abool {get;set;}
    public Boolean Bbool {get;set;}
   
    public sample()
    {
        Abool = false;
        Bbool = false;   
    }  
    public void callA()
    {
        Abool = true;
        Bbool = false;
    }  
    public void callB()
    {
        Abool = false;
        Bbool = true;   
    }    
}

1 comment: