+ Start a Discussion
kirubakaran viswanathankirubakaran viswanathan 

How to use the static text in multiple places within the same VF page?

For example, I have a text " Hello World", I need to use this text in the places in the VF page based on the Output render conditions at least 4-5 times in a page. I don't want to repeat this text hardcoded in the multiple places.

How can we achieve this without any extension/custom controller? Because in future I may need to change the text in Prod directly, rather than pushing the changes through Changeset.

P.S: I have really long text and I have multiple texts like this to be repeated.
Raj VakatiRaj Vakati
You can use it in the Custom label and call the values from the visualforce page


https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_variables_global_label.htm
​​​​​​​
<apex:page>
   <apex:pageMessage severity="info" 
   strength="1" 
   summary="{!$Label.firstrun_helptext}" 
   />
</apex:page>

 
kirubakaran viswanathankirubakaran viswanathan
Thanks Raj, Is there any other way we can achieve without custom Labels because, these text are not used across the company. It will be used only in this VF page and also, I may need some merge text field in that text. Not sure whether the Label can hold the merge fields and replace the value based on the record.
Raj VakatiRaj Vakati
That is the best way to do it my opinion .. Even if you use in apex class that class can be access able accross ogr 

You can able to populate the values using  Output and update labels using the format() expression function.


{!format($Label.mySection.myLabel, v.attribute1, v.attribute2)}

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/labels_parameters.htm