I want to test on "if" if the value inside bemSize is greater than 1, but salesforce does not recognize the bemSize variable, in the code it is simpler to understand, thanks for any help /o/ Controller:

global with sharing class CoberturasOrcamentoController  {
    private List<BemSegurado__c> bemSegurado2;
    public Integer bemSize;
    private Boolean varLMI;     
    private BemSegurado__c bemSeguradoUniq;
    private BemSegurado__c lmiuni;

public List <BemSegurado__c> getBemSegurado2(){
        bemSegurado2 = [
            SELECT Id, Name, NomeProprietario__c, ValorRisco__c, CPFCNPJ__c, TipoConstrucao__c, CEP__c, LocalRisco__c, ClasseBonusAnterior__c, Ocupacao__c, 
            QuantidadeSinistros__c, Identificacao__c, InformacoesComplementares__c, CodigoFrota__c, CI__c, NovaClasseBonus__c,
            ValorMercado__c, RecordType.DeveloperName, Nome__c, NomeBem__c, Marca__c, Modelo__c, Combustivel__c, AnoFabricacao__c, AnoModelo__c, Cor__c, 
            Placa_UF__c, TabelaFIPE__c, LotacaoMaxima__c, Chassi__c, Renavam__c, Rastreador__c, Sexo__c, DataNascimento__c, IdentificacaoMatricula__c,
            Certificado__c, SalarioBase__c,LMI_Unico__c
            FROM BemSegurado__c 
            WHERE Oportunidade__c =: opportunityId
            bemSize = bemSegurado2.size();//here the variable receives the size of the list

        return bemSegurado2;

 public Boolean getvarLMI(){
       lmiuni = getbemSeguradoUniq();
        if(lmiuni == null){
            varLMI = false;
            return false;
        } else {
            varLMI = true;
            return true;


<apex:component access="global" controller="CoberturasOrcamentoController">
    <apex:attribute name="quoteIdValue" type="String" description="This is the Id of the quote" assignTo="{!quoteId}" access="global" />
    <apex:attribute name="accountIdValue" type="String" description="This is the Id of the Account related to this quote" assignTo="{!accountId}" access="global" />
    <apex:attribute name="opportunityIdValue" type="String" description="This is the Id of the Opportunity related to this quote" assignTo="{!opportunityId}" access="global" />
<apex:outputPanel rendered="{!if(varLMI==false && bemSize>1 , true ,false)}"><!--here salesforce says it doesn't recognize obemSize...I don't understand why
                        <apex:repeat value="{!Cobertura}" var="cob">
                                <td style="text-align: left">{!cob.BemSegurado__r.Identificacao__c}</td>
                                <td style="text-align: left">{!cob.Opcoes_de_Coberturas__r.Name}</td>

the mistake: Unknown property 'CoberturasOrcamentoController.bemSize'

2 Answers 2


Visualforce (well, the renderer that converts your Visualforce into HTML that ends up getting sent to your browser) doesn't have a way to access the variables of a class directly. Instead, Visualforce accesses things by calling a method.

Most times (except for methods given in the action parameter of things like <apex:page> and <apex:pageButton>), Salesforce will try to call a method whose name stars with "get". This is an example of "convention instead of configuration". In your example, you used bemSize in your merge expression, so Salesforce is looking for a method called getbemSize() in your controller to call.

A class variable with a "getter" (and/or a setter) method makes it a property. Since you have no getbemSize() method, Salesforce gives you the error that it can't find a property named bemSize.

The solution here is to make bemSize a property by defining a getter. You could write that by hand, but Salesforce gives us a shortcut. By simply including {get; set;} (or, minimally, {get;}) in the declaraction of bemSize, Salesforce will automatically create the appropriate getter/setter behind the scenes.

So change from

public Integer bemSize;


public Integer bemSize {get; set;}

You should also look through Apex Properties for a more thorough explanation.

  • +1 for the link ! Commented Jan 26, 2022 at 16:39
  • thank you! Your explanation also helped a lot to understand how it works, I will definitely take a look at the link you passed
    – Souza
    Commented Jan 26, 2022 at 17:53

You need to add get ; set; in order to access apex class members on the client side. This could be similar to what you're already doing with varLMI. You defined a getter getvarLMI that returns the value of varLMI.

or you can simply mark the property as get set.

Update line #3 to

public Integer bemSize{ get; set; }
  • 1
    wow thank you!!!!!
    – Souza
    Commented Jan 26, 2022 at 17:51

You must log in to answer this question.

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