On a custom VF page, inside of an apex:repeat component I have two apex:outputPanel components. I want to show one apex:outputPanel when a checkbox field on the record is true/checked and I want to show the other when the checkbox field is false/unchecked. This seems easy enough to do but I'm getting hung up on the exact syntax.
I've tried using the field itself:
<apex:repeat value="{!responses}" var="response" id="responseRepeat">
<!-- show when false -->
<apex:outputPanel rendered="{!NOT(response.Checkbox__c)}">
The checkbox is false
</apex:outputPanel>
<!-- show when true -->
<apex:outputPanel rendered="{!response.Checkbox__c}">
The checkbox is true
</apex:outputPanel>
</apex:repeat>
checking if the field is true or false:
<apex:repeat value="{!responses}" var="response" id="responseRepeat">
<!-- show when false -->
<apex:outputPanel rendered="{!response.Checkbox__c == False}">
The checkbox is false
</apex:outputPanel>
<!-- show when true -->
<apex:outputPanel rendered="{!response.Checkbox__c == True}">
The checkbox is true
</apex:outputPanel>
</apex:repeat>
and an IF statement:
<apex:repeat value="{!responses}" var="response" id="responseRepeat">
<!-- show when false -->
<apex:outputPanel rendered="{!IF(response.Checkbox__c == False, true, false)}">
The checkbox is false
</apex:outputPanel>
<!-- show when true -->
<apex:outputPanel rendered="{!IF(response.Checkbox__c == True, true, false)}">
The checkbox is true
</apex:outputPanel>
</apex:repeat>
But no luck so far as I am only able to see the first panel (show when false) even when the checkbox is true. Any suggestions on what I'm doing wrong?
<apex:repeat value="{!responses}" var="response" id="responseRepeat">{!response.Checkbox__c}</apex:repeat>
Check what is being shown and if the checkbox__c is reallytrue
– Christoph Oct 6 '15 at 15:25<apex:outputPanel>{!IF(response.Checkbox__c, 'The checkbox is true', 'The checkbox is false')}</apex:outputPanel>
– Adrian Larson♦ Oct 6 '15 at 15:35