Can any one help me out ?Explain on ternary operator and how to use ternary operator in visual force page.Any Example .Any suggestion .Plz
-
1Could you get more information for your question? At the moment it is not clear what is the problem you are facing.– Sergej UtkoCommented Mar 24, 2015 at 12:29
-
1where exactly you want to use this ? in any specific attribute or in javascript ?– Vamsi Krishna GosuCommented Mar 24, 2015 at 12:29
Add a comment
|
1 Answer
I think there is no use case in Visualforce where it could be possible to use a ternary operator (at least all my attempts returned Error: Syntax error
).
What you may want to use is an IF Function:
IF(logical_test, value_if_true, value_if_false)
Example:
{!IF(someVariable == 'OK', 'it is ok', 'not ok')}
-
2I'd go so far as to say that the IF statement is a ternary operator, as it always requires three parameters, and the two branches must return compatible data types in at least most cases, making it identical in behavior with only a 4 character "penalty" over a ?: operator.– sfdcfox ♦Commented Mar 24, 2015 at 13:50