1

The documentation is not very clear.

Click here for SF documentation

3

As the official Doc says:

Return the label of an inputField component that is associated with a Message.

This applies to Message instances which are associated with specific components in the page - namely <apex:inputField /> elements. The global variable allows you to retrieve the field label in a generic manner when the Message is associated to a specific field.

Apex Message Class documentation which relates to this scenario.


Example:

You need to show the error messages of a DML operation on your VF. The validation rules and triggers will fill the messages collection setting the error message related to each field which has a problem.

Then, on your VF you could list the messages using a datalist and show the label of the fields that have errors along with the message text.

<apex:datalist var="mess" value="{!messages}">
  <apex:outputText value="{!mess.componentLabel}:" style="color:red"/>
  <apex:outputText value="{!mess.detail}" style="color:black" />
</apex:datalist>

Will show you:

  • Amount can not be lower than 100.
  • Close Date can not be empty.
1
  • Thanks for reply , but I am confused , what a datalist retruning here. List of string and why we are not user $ sign if its a global varible and Serially I am not able to understand the use case. If datalist is case list of wrapper class then componentLable must a property of this wrapper class. Actually SF did not specified the apex code here and making confusing like me people. Feb 3 '14 at 8:55

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.