1

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

5
  • What line is the error happening on?
    – BarCotter
    Apr 24 '14 at 10:21
  • The error is happening on for the following statement value="{!IF(mem.smoker__c == true,'Yes','No')}" Apr 24 '14 at 10:26
  • Is there any documentation about usage of inline Apex constructs in an visual force page? Apr 24 '14 at 10:28
  • is smoker__c definitely the name of the field in the members object, is it available to the page, and you are sure it is within this snippet of the VF page that the error is being generated?! (a good way to test would be to remove that evaluation and see if the page no longer generates this error) Apr 24 '14 at 10:52
  • Yeah I am very sure. There is no error seen if the line of code is removed. Also, if I give value="{!IF(mem.smoker__c == true,'Yes','No')}}" (here I have given an extra } before the expression ends) the value is retrieved properly but appended by a '}'. The value seen on the screen if the smoker__c is true is 'Yes}' and 'No}' is seen when smoker__c is false. Weird! A very likely apex bug. Apr 24 '14 at 12:14
2

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')}
4
  • There is no limitation on using the '==' or '!=' operators on checkbox/boolean fields in the IF formula operator. Apr 24 '14 at 10:41
  • Yep. That'd do it! Good spot. Apr 24 '14 at 11:06
  • Tried this. Still get the same error. Apr 24 '14 at 12:23
  • Try removing the apex:column from the VF page to make sure the page saves correctly. Once that is done then add some text e.g. <apex:outputText value="Test"/>, verify that the text appears. Then try <apex:outputText value="{!mem.smoker__c}/> to make sure that appears. Then finally try <apex:outputText value="{!IF(mem.smoker__c == true,'Yes','No')}"/>
    – BarCotter
    Apr 24 '14 at 13:02
0

{!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.

0

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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