function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
yogendra Aragula 8yogendra Aragula 8 

I have a picklist on a standard visualforce page. Based on the piclist value i want to display different page block section on the bottom of the page.

I have a picklist on a standard visualforce page. Based on the piclist value i want to display different page block section on the bottom of the page. I.e i want to divide the page in two sections.
Best Answer chosen by yogendra Aragula 8
Marcilio SouzaMarcilio Souza
In your object go in 'Buttons, Links, and Actions'
Choose Edit from 'New' (button) then override with your visual page.

But you have to use in your visualforce page standardController="CustomObject__c" than use extensions="CustomController".

All Answers

yogendra Aragula 8yogendra Aragula 8
User-added image
Marcilio SouzaMarcilio Souza
Hi,

You can create a custom visual force page and put in a section of the standard page.

In this visualpage you develop the section that display based in the picklist value.

A simplest example:
<apex:page  >
   <apex:pageBlock rendered="true">
 -- 
--
 </apex:pageBlock>
  

 <apex:pageBlock rendered="false">
  --
-- 
  </apex:pageBlock>

</apex:page>

You display in condition in your picklist.

Marcilio
yogendra Aragula 8yogendra Aragula 8
I am uisng visual force with Custom controller. Now i want to over ride standard "New" button with custom controller page. How can i achive that?
Becuase when i go that custom object new button, i cant see the VF page
Marcilio SouzaMarcilio Souza
In your object go in 'Buttons, Links, and Actions'
Choose Edit from 'New' (button) then override with your visual page.

But you have to use in your visualforce page standardController="CustomObject__c" than use extensions="CustomController".
This was selected as the best answer
JaiChaturvediJaiChaturvedi
Hi,

If you want different actions on picklist value then use actionSupport with the picklist. In actionSupport you have to use onChange event and fire method.

You have to create output panel and use alter rendered value on pageBlock in your apex method.
 
<apex:selectList value="{!PicklistValueList}" >
            <apex:selectOption itemValue="one" />
            <apex:selectOption itemValue="two" />
            <apex:selectOption itemValue="three" />
            <apex:actionSupport event="onchange" action="{!ApexClassAction}" rerender="OutputPanelId" status="myStatus2" />
        </apex:selectList>
yogendra Aragula 8yogendra Aragula 8
Hi Marcilio Souza,

Its working fine but i want the default value to be none is the picklist and when i am selection FLS picklist value , the page block is getting displayed.

Class:

public class display { 
    public display(ApexPages.StandardController controller) {

    }


    
    //To store the picklist value which we have selected on VF page i.e (Ind, Aus, USA)
    public String country { get; set; }    
    
    //To display list of picklist values on VF page
    public List<selectOption> getPicklistvalues() {
        List<selectOption> options = new List<selectOption>();       
        options.add(new selectOption('None','None'));
        options.add(new selectOption('FLS','FLS'));
        options.add(new selectOption('Object Permission','Object Permission'));
        options.add(new selectOption('Others','Others'));
        
        return options;
    }   

    //To make three pageblocksections invisible by default
    public Boolean indtf = false;
    public Boolean Ind1tf = false;
    public Boolean Ind2tf = false;
    public Boolean austf = false;
    public Boolean usatf = false;
       
    //To dynamically pass Boolean values to rendered attribute on pageblocksection
    public void setInd(Boolean b) {
        this.indtf = b;
    }
    public Boolean getInd() {
        return this.indtf;
    }    
    
    public void setAus(Boolean b) {
        this.austf = b;
    }
    public Boolean getAus() {
        return this.austf;
    }
    
    public void setInd1(Boolean b) {
        this.Ind1tf = b;
    }
    public Boolean getInd1() {
        return this.Ind1tf;
    }
    
    public void setUsa(Boolean b) {
        this.usatf = b;
    }
    public Boolean getUsa() {
        return this.usatf;
    }
   
    public void setInd2(Boolean b) {
        this.Ind2tf = b;
    }
    public Boolean getInd2() {
        return this.Ind2tf;
    }
 
    //Constructor, After loading the page to display india pageblocksection by default
    public display() {
        setInd(True);
        setInd1(False);
        setInd2(False);
    }
    
    //After changing picklist value based on the selection to display either usa or aus pageblocksection
    //Through actionfunction or actionsupport this method will be called to VF page
    public PageReference selectcountry() {
        if(country == 'FLS') {
            setInd(False);
            setInd1(True);
            setInd2(False);
        }
        else {
            setInd(False);
            setInd1(False);
            setInd2(True);
        }
        return null;
    }
}

Page:

<apex:page standardController="Post_Deployment_Step__c" extensions="display">
    <apex:form >
    <apex:pageBlock >
    <apex:pageBlockSection title="Select the Type">
    <apex:outputLabel > <b>Input Data Type : </b> </apex:outputLabel>
        &nbsp; &nbsp;
      <!--<apex:actionFunction action="{!selectcountry}" name="fun"/>
      <apex:selectList size="1" value="{!country}" onchange="fun();">-->
      </apex:pageBlockSection>
      <apex:selectList size="1" value="{!country}">
      <apex:actionSupport event="onchange" action="{!selectcountry}"/>
      <apex:selectOptions value="{!picklistvalues}">
          </apex:selectOptions>
      </apex:selectList>
      </apex:pageBlock>
      <apex:pageBlock >
       <!--renderd to display or hide the pageblocksection on any other element of VF page-->
       <apex:pageBlockSection title="FLS" rendered="{!Ind}">
           <b>Need to Display FLS Fields as per Input Files</b>
       </apex:pageBlockSection>
       
       <apex:pageBlockSection title="Object Permission" rendered="{!Ind1}">
           <b>Need to Display Object Permission Fields as per Input Files</b>
       </apex:pageBlockSection>
       
       <apex:pageBlockSection title="Others" rendered="{!Ind2}">
           <b>Need to Display  Fields as per Input Files</b>
       </apex:pageBlockSection>
       
       
      </apex:pageBlock>
    </apex:form>      
</apex:page>

Can you please check it once