You need to sign in to do that
Don't have an account?

VF Syntax problem / bug
Can anybody tell me why this is the case, or is it just a compiler bug?
This line fails during compile with the error
<apex:column headerValue="XXX" value="{!if(rel.Child__c==null,'Contact','Child')}"/>
Save error: Syntax error. Missing ')'.
(rel.child__c is a valid object, valid field, etc. that's not the problem. )
If I change rel.child__c to a constant value, it compiles correctly. (albeit it's sort of a meaningless thing to do)
If I leave rel.child__c in place and remove the header_value='XXX', it compiles correctly.
Lastly, if I change the line to:
<apex:column headerValue="XXX" value="{!if(rel.Child__c==null,'Contact','Child')}PEANUTS"/>
it compiles correctly. It doesn't have to be "PEANUTS", adding anything, even a space let's it compile.
Clearly there's something wrong. And, regardless, it's a really bad error message. I'd file a bug but I wonder if someone has a logical explanation like it does something when evaluating the Value that's different depending on if it's within a formula or without, etc. Strange.
Best, Steve.
I don't have an explanation for you for why this is happening. apex:column does have some special behavior to it, like if it's bound to an sObject field it will use an outputField instead of an outputText to display your value. Maybe something in the compiler is getting hung up on that.
As mentioned the workaround is to move the value into the body of your column component. I've logged a bug for this internally in the meantime.
All Answers
I am not sure , but what I could understand after a lot playing with value attribute:
Basically, This syntex is not allowed in salesforce:
<apex:column headerValue="XXX" value=""/>
When you write this, it gives :
Error: Formula expression is required for attribute value in <apex:column>
So when you are writing:
<apex:column headerValue="XXX" value="{!if(rel.Child__c==null,'Contact','Child')}"/>
it's unable to identify, what the output will be. B'coz if your formula returning a blank value then it will be a run time exception.
like:
<apex:column headerValue="XXX" value="{!if(rel.Child__c==null,'','')}"/>
That's why it is asking for a some constant value.
Is this make sense ?
Steve,
In my experience, putting anything fancy in the value attribute of a column tag does not work very well. Try putting it in the body of the tag instead, like this:
--Sarah
I don't have an explanation for you for why this is happening. apex:column does have some special behavior to it, like if it's bound to an sObject field it will use an outputField instead of an outputText to display your value. Maybe something in the compiler is getting hung up on that.
As mentioned the workaround is to move the value into the body of your column component. I've logged a bug for this internally in the meantime.
Thanks for filing the bug! :-) Steve.
Saraha... Thank you very very much !!!