1

I have a map from which i get the value in visualforce. How do I use the redner condition to check that if the falue is empty it will not render. I get the error:

Incorrect parameter type for function 'not()'. Expected Boolean, received Object

See my visualforce:

  <apex:outputtext rendered="{!IF(!candidateFieldMap != null,true, false)}">
                    <span class="header">motivation</span><br />
                         <cxsrec:getMapValue map="{!candidateFieldMap.PersonalMotivation__c}" key="PersonalMotivation__c" /><br /> 
                    </apex:outputText>

2 Answers 2

0

Try ISNULL() or ISBLANK() and use capital letters for NOT()

rendered="{!NOT(ISNULL(candidateFieldMap))}"

Or avoid NOT() altogether:

rendered="{!IF(ISNULL(candidateFieldMap),false,true)}"
3
  • This returns: Incorrect parameter type for function 'not()'. Expected Boolean, received Object
    – Thomas
    Jul 23, 2019 at 13:42
  • I edited my answer - try the 2nd one Jul 23, 2019 at 16:39
  • 1
    no reason to use IF -- simpler: rendered="{!NOT(ISNULL(candidateFieldMap))}" - that said testing for null collections in VF is problematic at times without controller support
    – cropredy
    Jul 23, 2019 at 23:32
0

Try this:

Create a Boolean property in Apex class to check if the map is empty, and use that for rendered tag:

public boolean getIsCandidateMapEmpty() {
    return candidateFieldMap.size() == 0;
}

Then, in vf page:

rendered="{!NOT(IsCandidateMapEmpty)}"

reference: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_variables_functions.htm

3
  • This returns: Unknown property 'cxsrec.cxsSmartMap.PersonalMotivation__c'
    – Thomas
    Jul 23, 2019 at 13:37
  • Sry, u need to check if NOT Jul 23, 2019 at 13:38
  • This returns: Incorrect parameter type for function 'not()'. Expected Boolean, received Object
    – Thomas
    Jul 23, 2019 at 13:42

You must log in to answer this question.

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