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
robert webber 8robert webber 8 

Pageblock not supposed to render after selectList change

I've spent hours trying to solve this. I've boiled it down to the following VF test page below. When I change the "Plan" selectList and there is no data, the pageBlockSection is not supposed to render since SalesInvestmentPlanData.HavePlan1Data and SalesInvestmentPlanData.HavePlan2Data are false. "UpdateDashboard" runs from the constructor, and also when the Plan selectList changes. I set HavePlan1Data and HavePlan2Data to false in the test code that runs in the controller shown below the VF. When the page loads, the pageBlockSection is not rendered, which is what I expect. When I change the Plan selectList, I get the error "Expected at least 1 rendered series component", implying that the pageBlockSection is rendering  but the Line Series are not rendering. Presume this is something obvious but just can't see why the pageBlock is rendered on the selectList change when HavePlan1Data and HavePlan2Data are hard-coded to false.  Greatly appreciate help on this.  PS I put this in a panelgrid because there are more charts in the original VF page. Thanks.

<apex:page StandardController="Investment_Plan__c" extensions="FinancialDashboardControllerTest" sidebar="False" LightningStyleSheets="True">
    
    <apex:pageBlock >
        <apex:form >
            <apex:pageBlockSection collapsible="False" columns="2">               
                <apex:selectList value="{!selectedOption}" size="1" label="Plan 1">
                    <apex:actionSupport event="onchange" action="{!UpdateDashboard}" rerender="idSelectedResourceScenario,idSelectedDate,idFinancialData"/>
                    <apex:selectOptions value="{!selectPlanOptions}"/>
                </apex:selectList>               
                <apex:selectList value="{!selectedResourceScenario}" size="1" label="Resource Scenario" id="idSelectedResourceScenario">
                    <apex:actionSupport event="onchange" action="{!UpdateDashboard}" reRender="idSelectedDate,idFinancialData"/>                    
                    <apex:selectOptions value="{!selectedResourceScenarioOptions}"/>
                </apex:selectList>               
                <apex:selectList value="{!selectedDate}" size="1" label="Projection Date" id="idSelectedDate">
                    <apex:actionSupport event="onchange"  rerender="idCharts"/>                    
                    <apex:selectOptions value="{!selectedDates}"/>
                </apex:selectList>               
            </apex:pageBlockSection>
        </apex:form>
    </apex:pageBlock>   
    <apex:pageBlock>
        <apex:pageBlockSection columns="1" id="idFinancialData" rendered="{!If(SalesInvestmentPlanData.HavePlan1Data || SalesInvestmentPlanData.HavePlan2Data,'True','False')}">
            <apex:messages/>
            <apex:panelGrid columns="1" id="idCharts">               
                <apex:outputPanel>                                        
                    <apex:chart height="300" width="510" data="{!SalesInvestmentPlanData.PlanData}">
                        <apex:legend position="bottom"/>
                        <apex:axis type="Numeric" position="left" fields="data1" minimum="0" maximum="{!SalesInvestmentPlanData.MaxPlanData}"/>   
                        <apex:axis type="Category" position="bottom" fields="name" >
                        </apex:axis>
                        <apex:lineSeries axis="left" xField="name" yField="data1" title="Plan 1"
                                         markerType="cross" markerSize="4" markerFill="#FF0000" rendered="{!If(SalesInvestmentPlanData.HavePlan1Data,'True','False')}"/>
                        <apex:lineSeries axis="left" xField="name" yField="data2" title="Plan 2"
                                         markerType="circle" markerSize="4" markerFill="#8E35EF" rendered="{!If(SalesInvestmentPlanData.HavePlan2Data,'True','False')}"/>           
                    </apex:chart>                                                        
                </apex:outputPanel>               
           </apex:panelGrid>
        </apex:pageBlockSection>
    </apex:pageBlock>   
</apex:page>

"Update Dashboard"
    public pageReference UpdateDashboard() {
        salesReturnData.HavePlan1Data = False;
        salesReturnData.HavePlan2Data = False;
        return null;
        }






 
Alain CabonAlain Cabon
Hi,

How did you define exactly salesReturnData.HavePlan1Data and  salesReturnData.HavePlan2Data ?

With static ? {get;set} ?

That is important for the view state.

Enabling the View State Tab

To enable the View State tab:
  1. From your personal settings, enter Advanced User Details in the Quick Find box, then select Advanced User Details. No results? Enter Personal Information in the Quick Find box, then select Personal Information.
  2. Click Edit.
  3. Select the Development Mode checkbox if it isn't selected.
  4. Select the Show View State in Development Mode checkbox.
  5. Click Save.
https://help.salesforce.com/articleView?id=code_dev_console_tab_view_state.htm&type=5
 
robert webber 8robert webber 8
ScenarioFinancialSummaryClass.InvDataLists salesReturnData = new ScenarioFinancialSummaryClass.InvDataLists();
I have a getter for it:

    public ScenarioFinancialSummaryClass.InvDataLists getSalesInvestmentPlanData() {
       system.debug(LoggingLevel.Info, '****** salesData = '+salesReturnData);
       return salesReturnData;
    } //end getSalesInvestmentPlanData

The class definition is from ScenarioFinancialSummaryClass:

    Public Class InvDataLists {
        Public Boolean HavePlan1Data{get; set;}
        Public Boolean HavePlan2Data{get;set;}
        Public String StartFYSuffix{get;set;} //fiscal years are synched to the same FY
        Public List<InvPlanData> PlanData{get; set;}
        Public Integer MaxPlanData{get;set;}
        Public List<InvPlanData> CumData {get; set;}
        Public Integer MaxCumData {get;set;}
        Public ComparisonDataClass PlanDeltas {get; set;}
        Public ComparisonDataClass CumDeltas {get; set;}
    }

It seems that the each of the line series in the chart is getting value "False" . Don't understand why the pageBlock that contains the chart is not seeing False and not rendering.

Thanks,

Bob