Using rendered attribute in Visualforce Pages

The scenario is:
1. Initially pb1 is visible and pb2 is invisible 
2. After clicking the command button pb1 will go invisible and pb2 is visible.

<apex:page controller="renderTestController">
<apex:form >
 <apex:pageBlock title="Block 1" id="pb1" rendered="{!pb1}">
 <apex:commandButton value="Select" action="{!dosel}"/>

 <apex:pageBlock title="Block 2" id="pb2" rendered="{!pb2}">

 <apex:pageblocktable title="Account Table" value="{!acclist}" var="a">
 <apex:column >
 <apex:inputtext value="{!}" />



public class renderTestController {
    public List<account> acclist {get;set;}
    public Boolean pb1 {get;set;}
    public Boolean pb2 {get;set;}
    public renderTestController ()
    pb1 = true;
    pb2 = false;
    acclist = new List<account>();

    public PageReference dosel() {
    acclist = [SELECT Name FROM Account];
    pb1 = false;
    pb2 = true;
        return null;



Popular Posts