I want to Render a section of my Visualforce page only if I found Opportunities related to the Account I'm working with and I'm getting this error message. I have a VF Page and a controller extension.

    <apex:page standardController="Account" extensions="MyControllerExtension" action="{!init}">
        <apex:pageBlock TITLE="Company" id="theBlock">
            <apex:outputText value="Have you created a new opportunity "/>
            <apex:pageBlockSection columns="1">
               <!-- <apex:selectRadio value="{!BooleanOptions}">
                    <apex:selectOptions value="{!yesNo}"/>
                </apex:selectRadio > -->

        <apex:pageBlockSection Title="Opportunities related to this Account" rendered="{!hasOpp}">
            <apex:pageBlockTable value="{!showOpps}" var="opp" width="500">
                <apex:column headervalue="Opportunity Name" value="{!opp.Name}" />
                <apex:column headerValue="Closed Date" value="{!opp.CloseDate}" />
                <apex:column headerValue="Opportunity Stage"  value="{!opp.StageName}" />
    <apex:pageMessages ></apex:pageMessages>
    <apex:outputField value="{!Account.Name}" rendered="false" />
    <apex:outputField value="{!Account.MasterId__c}" rendered="false" />
    <apex:outputField value="{!Account.CDS_Company_ID__c}" rendered="false" />
    <apex:outputField value="{!Account.OwnerId}" rendered="false" />

This is the controller ext:

public with sharing class MyControllerExtension {
    private final Account acct;

    public MyControllerExtension(ApexPages.StandardController stdController) {
        this.acct = (Account) stdController.getRecord();

    /*public List<SelectOption> getYesNo() {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('true', 'Yes'));
        options.add(new SelectOption('false', 'No'));
        return options;
    } */

    public boolean hasOpp {
       get {
           List<Opportunity> oppList = new List<Opportunity>([SELECT Id FROM Opportunity WHERE Account.Id = :acct.Id]);
           return (oppList.IsEmpty());
        private set;

    public List<Opportunity> showOpps() {
        List<Opportunity> oppList = new List<Opportunity>();

        if (acct.Id != null){
            oppList = [SELECT Name, Amount, CloseDate, StageName FROM Opportunity WHERE Account.Id =: acct.Id ];
            return oppList;
        } else {
            oppList = null;
            return oppList;

    public PageReference init() {
        String CompanyId = acct_Company_ID__c;
        if (String.isEmpty(CompanyId)) {
            ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.INFO, 'The new account setup process is not yet available for this company. Please try again in a few minutes.'));
            return null;

        System.debug('salesforceId:' + acct.Id);

        // Get "Landing Page" where user will be taken to open or check existing account.
        PageReference page = new PageReference(EnvironmentSettings.getOpenAccountUrl());
              page.getParameters().put('salesForceId', acct.Id);

        return page;


The error is thrown on this line in my VF Page:

<apex:pageBlockSection Title="Opportunities related to this Company" rendered="{!hasOpp}">

Even though I have a get and set on hasOpp (in my ext controller), not sure what I'm missing. Thanks.

  • what's the error message? Apr 11, 2017 at 18:04
  • Error is with showOpps, its must be getShowOpps() in controller
    – Raul
    Apr 11, 2017 at 18:05

1 Answer 1


The line of markup that is actually throwing your error is one further down:

<apex:pageBlockTable value="{!showOpps}" ...>

The reason is that you declared showOpps as a method, not a property.

Method Syntax

public List<Opportunity> showOpps()
    // cannot reference showOpps as a property

Property Syntax

public List<Opportunity> getShowOpps()
    // can reference showOpps as a property

Getter Syntax

public List<Opportunity> showOpps
        // can reference showOpps as a property

    private set;
    // having any setter is optional
    // use the private access modifier if you do declare one
    // there's no good reason to leave it public

You must log in to answer this question.

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