Find your content:

Search form

You are here

Error while using IF in inline Visual force page

 
Share

I am using an inline IF expression for the value attribute of an <apex:column> inside an <apex:pageBlockTable>.

The code is as follows:

<apex:pageBlockTable var="mem" value="{!allMembers}">
            <apex:column value="{!mem.Name}" onclick="onClickMember('{!mem.Id}')" styleclass="{!IF(selectedMember.member.Id == mem.Id,'ui-state-active','')}">
            </apex:column>   

            <apex:column value="{!IF(mem.smoker__c == true,'Yes','No')}" onclick="onClickMember('{!mem.Id}')" styleclass="{!IF(selectedMember.member.Id == mem.Id,'ui-state-active','')}">
            </apex:column> 

            <apex:column value="{!mem.Eligible_Program__r.Name}" onclick="onClickMember('{!mem.Id}')" styleclass="{!IF(selectedMember.member.Id == mem.Id,'ui-state-active','')}">
            </apex:column>

            <apex:column headerValue="Plan Chosen"><apex:inputCheckbox /></apex:column>

   </apex:pageBlockTable>

The error thrown is:

Visualforce Error

Syntax error. Missing ')' Error is in expression '{!IF(mem}' in component <apex:pageBlockTable> in page vf_plan_selection


Attribution to: Nitin Kundapur Bhat

Possible Suggestion/Solution #1

The value attrbute of apex:column needs to be an SObject field which its not in your example.

You need to change:

 <apex:column value="{!IF(mem.smoker__c == true,'Yes','No')}" onclick="onClickMember('{!mem.Id}')" styleclass="{!IF(selectedMember.member.Id == mem.Id,'ui-state-active','')}">
            </apex:column> 

To something like this:

        <apex:column headerValue="Smoker">
            <apex:outputText value="{!IF(mem.smoker__c == true,'Yes','No')}"/>
        </apex:column>

On a side note:

If the smoker__c field is a boolean then there is no need for the mem.smoker__c == true comparison

Try changing this:

{!IF(mem.smoker__c == true,'Yes','No')}

To this:

{!IF(mem.smoker__c,'Yes','No')}

Attribution to: BarCotter

Possible Suggestion/Solution #2

{!IF(mem}

It looks as like the error you've posted is happening outside of the code block you posted.

This is opening the IF statement with left paren ( and closing it with right bracket }, which does not happen in the snippet you posted.

Unfortunately Visualforce errors don't give you line numbers, so it's hard to find exactly there the error is. I'd suggest looking in your page for a place where you're accidentally using a right bracket instead of a right parentheses.


Attribution to: Ray Dehler

Possible Suggestion/Solution #3

Try like this

<apex:column>
    <apex:facet name="header"></apex:facet>
    <apex:outputText value="Yes" rendered="{!mem.smoker__c}" />
    <apex:outputText value="No" rendered="{!!mem.smoker__c}" />
</apex:column>

Attribution to: SANN3
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/33557

My Block Status

My Block Content