New Batch#100 (10th Nov 2021) - Salesforce Admin + Dev Training (WhatsApp: +91 - 8087988044) :https://t.co/p4F3oeQagK

Saturday 4 August 2012

Display pageblocks based on the picklist selection

I got only partial Result, The challange is how to retrieve the selected values of picklist and compare them

VF

<apex:page controller="coun">
<apex:form >
<apex:selectlist label="Countries" size="1" value="{!country}">
<apex:actionSupport event="onchange" action="{!india}" rerender="India"/>
<apex:selectoption itemlabel="None" itemvalue="None"/>
<apex:selectoption itemlabel="India" itemvalue="India">
</apex:selectoption>
<apex:selectoption itemlabel="US" itemvalue="Us"/>
<apex:selectoption itemlabel="UK" itemvalue="Uk"/>
</apex:selectlist>
<apex:pageBlock >

<apex:outputPanel id="India">
<apex:pageBlockSection title="India" rendered="{!mhide}">
</apex:pageBlockSection>
</apex:outputPanel>

<apex:outputpanel id="Us">
<apex:pageBlockSection title="US" rendered="{!m1hide}">
</apex:pageBlockSection>
</apex:outputpanel>

<apex:outputpanel id="Uk">
<apex:pageBlockSection title="UK" rendered="{!m2hide}">
</apex:pageBlockSection>
</apex:outputpanel>

</apex:pageBlock>

</apex:form>
</apex:page>

APEX

public class coun {

    String country;
    public String getCountry() {
        return this.country;
    }
    public void setCountry(String counrty) {
        this.country = country;
    }
   
    public Boolean hide = false;
    public Boolean hide1 = false;
    public Boolean hide2 = false;
   
    public void setMhide(Boolean b) {
    this.hide = b;
    }
   
    public Boolean getMhide() {
    return this.hide;
    }
   
   
    public Boolean getM1hide() {
        return this.hide2;
    }
   
    public void setM1hide(Boolean b) {
      this.hide2 = b; 
    }
   
   
    public Boolean getM2hide() {
        return this.hide1;
    }
   
    public void setM2hide(Boolean b) {
        this.hide1 = b;
    }
   
   
    public PageReference india() {
       //if(country == 'India') {
        setMhide(true);
        setM2hide(false);
        setM1hide(false);
       // }      
        return null;
    }
   
     public PageReference us() {
        setM1hide(true);
        setM2hide(false);
        setMhide(false);
        return null;
    }
   
    public PageReference uk() {
        setM2hide(true);
        setM1hide(false);
        setMhide(false);
        return null;
    }  
   
}

No comments:

Post a Comment

Labels