[SalesForce] Render if variable contains text value in visualforce

I am trying to use render if condition on a viasualforce based on a value containing a string but this seems not to work. What am I missing? See:

        <apex:pageBlock title="Manuals">
        <apex:pageBlockTable value="{!urlmap}" var="key">
            <apex:column value="{!key}"/>
            <apex:column width="150px">
                 <apex:outputtext rendered="{IF(CONTAINS({!key},'Manual'),true, false)}">
                <apex:outputLink value="{!urlmap[key]}">Click here to download</apex:outputLink>
                </apex:outputtext>
            </apex:column>
        </apex:pageBlockTable>
    </apex:pageBlock>

Best Answer

Merge field is not required for variable already inside a merge fields, so the expression should go inside {! }:

<apex:outputtext rendered="{!IF(CONTAINS(key,'Manual'), true, false)}">
    <apex:outputLink value="{!urlmap[key]}">Click here to download</apex:outputLink>
</apex:outputtext>

You could get rid of IF as CONTAINS(key,'Manual') returns a Boolean already.

Related Topic