Here is the Visualforce code:

<apex:panelGrid id="pgId1" columns="13" cellpadding="4" cellspacing="0" styleClass="tblFilters">
    <apex:outputLabel value="Show Plan: " />
    <apex:selectList value="{!strShowPlanType}" size="1" required="true" id="slIdPlan" style="width:87px;">
        <apex:selectOptions value="{!ShowPlan}"/>  
        <apex:actionSupport action="{!SelectCurrentMonthQuarterYearAsDefault}" status="contentLoadingStatus" event="onchange" reRender="pgId1,slIdMonth,slIdQuarter"/>  

    <apex:outputLabel value="Select Quarter: " rendered="{!IF(strShowPlanType == 'Quarterly',true,false)}" /> 
    <apex:selectList value="{!strQuarter}" size="1" rendered="{!IF(strShowPlanType == 'Quarterly',true,false)}" required="true" id="slIdQuarter">
        <apex:selectOptions value="{!Quarter}"/>  

    <apex:outputLabel value="Select Month: " rendered="{!IF(strShowPlanType == 'Monthly',true,false)}" /> 
    <apex:selectList value="{!strMonth}" size="1" required="true" id="slIdMonth" rendered="{!IF(strShowPlanType == 'Monthly',true,false)}">
        <apex:selectOptions value="{!Month}"/>  

    <apex:outputLabel value="Select Year: "/ > 
    <apex:selectList value="{!strYear}" size="1" required="true" id="slIdYear" style="width:81px;">
        <apex:selectOptions value="{!Year}"/>  

Here is the corresponding apex action function called by actionsupport:

public pageReference SelectCurrentMonthQuarterYearAsDefault()
    Date currentDate = system.today();

    strMonth = mapFullNameofMonth.get(currentDate.month());
    strYear = string.valueOf(currentDate.Year());

    integer quarterNo = integer.valueOf(math.ceil(decimal.valueOf(currentDate.month()) / 3.0));
        strQuarter = quarterNo == 1 ? 'First Quarter' : (quarterNo == 2 ? 'Second Quarter' : (quarterNo == 3 ? 'Third Quarter' : 'Fourth Quarter'));    
    return null;

SelectMonth label& selectlist not getting rendered after selecting show plan value as 'Monthly'.

  • Added outputpanel before panelgrid...tried to rerender it on selecting plan;not working either.
    – piyush27
    Commented Nov 4, 2016 at 15:05

2 Answers 2


It has reasons of not working.

When you use actionSupport function for first selectList it will call controller method. Now during execution, property values are assigned first, followed by method call.

Now, think of the scenario, you are selecting the first selectList and at that moment all these mandatory fields have not been entered, so actionSupport will not get executed properly.

So, either you can remove required attribute from the page or use actionFunction instead of actionSupport to pass value to controller or performing any action.


Removed required=true from selectlist...working now..Don't know the reason why it worked!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .