Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I have an apex element which relies on the output of two Boolean methods to be rendered.

At the moment, both methods are evaluating to true, yet the apex element is not rendering. If I reverse one of the methods to evaluate to false, the element renders.

So the following DOES NOT render:

<apex:outputLink rendered="{!isTrue && !isTrue}"> //true && true

</apex:outputLink>

But this DOES render:

<apex:outputLink rendered="{!isTrue && ! !isTrue}"> //true && false

</apex:outputLink> 

I'm checking that the methods really are returning what I'm expecting them to by outputting them into the console.

console.log('{!isTrue}'); //true
console.log('{! !isTrue}'); //false

Am I using the rendered attribute incorrectly?

Can anyone spot what's wrong here?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

{!} is merge syntax

Adding parentheses may help visualize what is happening in your evaluations.

true and not true == false

<apex:outputLink rendered="{! (isTrue && !isTrue) }"> 

true and not not true (true to false and then back to true) == true

<apex:outputLink rendered="{! (isTrue && !!isTrue) }"> 
share|improve this answer
    
Ah! Cheers Mark, that cleared things up for me! –  Daft Sep 3 at 16:05
    
for clarity, you could use the NOT function rather than confuse yourself with the overloaded ! operator as in: <apex:outputLink rendered="{! cond1 && NOT(cond2) }"> –  crop1645 Sep 3 at 23:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.