3

So in my rendered attribute I am calling a getter method that returns a boolean. However I want to set rendered to the opposite of what it returns because it is used to render one component or another. What is the correct syntax for doing this?

I am aware that I can do this:

rendered="{!IF(selectedNameIsContact == false, true, false)}"

But I was hoping for a cleaner syntax such as

rendered="NOT{!selectedNameIsContact}"

1 Answer 1

4

You just need to use double '!!'. It looks funky, but it accomplishes what you are looking for

rendered="{!!selectedNameIsContact}"

EDIT

As pointed out by @sfdcfox, you could also use

rendered="{!not selectedNameIsContact}"

Also pointed out by @Ralph, you could also use

{!selectNameisContact == false}
5
  • 2
    Also, rendered="{!not selectedNameIsContact}". I'd avoid using !! directly, because it might be construed as a typo later.
    – sfdcfox
    Commented Jul 1, 2014 at 19:24
  • Good point @sfdcfox. Added to reflect. Commented Jul 1, 2014 at 19:25
  • The not does look a lot better than the double exclamation. Thanks for the input Commented Jul 1, 2014 at 19:38
  • 2
    where is {!not someBooleanFieldOrProperty} documented? I would have done this as {!NOT(someBooleanFieldOrProperty)}
    – cropredy
    Commented Jul 1, 2014 at 20:04
  • you've also got {!selectNameisContact == false} as an option Commented Jul 1, 2014 at 20:51

You must log in to answer this question.

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