Skip to main content
2 of 2
fixed md formatting for code and added titles.
pchittum
  • 19.8k
  • 5
  • 57
  • 99

#Page:

<apex:page controller="picklistRenderController">
<apex:form >
<apex:pageBlock >
    <apex:selectList value="{!selectId}" size="1">
        <apex:selectOptions value="{!display}"></apex:selectOptions>
        <apex:actionSupport event="onchange" action="{!displayButton}" reRender="buttons"/>
    </apex:selectList>
    <apex:pageBlockButtons location="bottom">
    <apex:outputPanel id="buttons">
        <apex:commandButton action="{buttonA}" value="Button A" rendered="{!Y}"/>
        <apex:commandButton action="{buttonB}" value="Button B" rendered="{!X}"/>
        </apex:outputPanel>
    </apex:pageBlockButtons>
 </apex:pageBlock>
</apex:form>
</apex:page>

#Class:

public class picklistRenderController
{

public List<selectOption> display { get; set; }
public String selectId { get; set; }
public Boolean X { get; set; }
public Boolean Y { get; set; }

public picklistRenderController() 

{


    Y=True;
    display= new List<selectOption>();
    display.add(new selectoption('none','-select-'));
    display.add(new selectoption('Show','Show'));
    display.add(new selectoption('Hide','Hide'));
}

 public void displayButton()
 
  {
  
     
     if (selectId =='Show')
     X=True;
     else
     X=False;
                     
  }
  
 
    

public PageReference buttonA()

 {
    return null;
    
 }
 
 
  public PageReference buttonB()

 {
    
    return null;
 }

}