function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

<apex:outputField /> Data binding multiple data

Hi there,


Why can't I Data bind multiple data to the outputField?



<apex:outputField value="{!member.Contact.MailingCountry}{!member.Lead.Country}" />


I know I could use two outputField to archieve the same thing, but I am just wondering why I can't do the above? I was able to do that in <apex:column /> tag, but not in <apex:outputField />


This works:


<apex:column value="{!member.Contact.MailingCountry}{!member.Lead.Country}" headerValue="Country"/>



Because outputField, like inputField, is a special component meant to work with object attributes. It displays different components (text, a read-only checkbox, etc.) depending on the underlying type of the object attribute.


When you try to concatenate two separate expressions (as you have), it's not possible for outputField to determine what sort of widget it should use (what if one of them is text and the other is boolean, for example)?


You can use outputText to get what you want.