You need to sign in to do that
Don't have an account?
How to add a HTML break in a Custom Label
Hi,
I'm using custom labels on my visualforce page. This generally works ok however in a popup screen I have when the custom label is long the apex:pagemessage displays funny (the severity icon is overlapped with the text(. I was thinking that I could get around this by adding line breaks into the Custom Label but a <br> tag cannot be added when creating a custom label. Does anyone know if there is a way to do something like this? I know can be used to add spaces. For a line break is there a similar non <br> tag which cab be used? Or is there a way of escaping the <br> when I try to add it to the custom label?
Thanks in advance for any suggestions.
Hi,
You can try from user interface Custom Labels,then you will not face this issue.
ok anyway
Now you can try like below syntax. it is working fine.
All Answers
Hi,
There is a way for this
I am giving an example for custom Label for this:
EX: point 1'+'\n'+'point 2'+'\n'+'point3
In the value of custom Label give like as above(modify accordingly)
Now in UI it will be displayed like below
Point 1
Point 2
Point 3
Is this resolves your problem or you are looking for some other..
Let me know..
Hi HariDinesh,
Thank you for your help/suggestion. I've tried this out and the \n actually displays in my apex:pageMessages in which the custom label is displayed instead of adding a HTML line break. I've tried escape="false" in my apex:pageMessages tag also
<apex:pageMessages escape="false"/>
Do you know if I need to add another change to make it to work?
Thanks again.
Ok,
Yes, It works for showing labels in Java script Alert messages, might not suit for you.
As you specified in first post For <apex: pageMessage component the below code will be works
Label content like this This is </br> test label.
Now for showing message in <apex:pageMessages like you expected try below
VFP:
Apex Class
Custom Label: This is </br> Test Label <br> second Line
Hi HariDinesh, Thanks for your suggestions. I think the main problem though lies in that I cannot save the Custom Label if using <br>'s
if I try
<labels>
<fullName>PasswordSuccessMessage</fullName>
<language>en_US</language>
<protected>true</protected>
<shortDescription>ApexPage Message On Successful Password Reset</shortDescription>
<value>This is </br> Test Label <br> second Line</value>
</labels>
I get
Description Resource Path Location Type
Save error: CustomLabels : Error parsing file: The element type "value" must be terminated by the matching end-tag "</value>". CustomLabels.labels /TestWebSites/src/labels line 288 Force.com save problem
If I try
<labels>
<fullName>PasswordSuccessMessage</fullName>
<language>en_US</language>
<protected>true</protected>
<shortDescription>ApexPage Message On Successful Password Reset</shortDescription>
<value>This is </br> Test Label </br> second Line</value>
</labels>
I get
Description Resource Path Location Type
Save error: CustomLabels : Error parsing file: Unexpected element {http://soap.sforce.com/2006/04/metadata}br during simple type deserialization CustomLabels.labels /TestWebSites/src/labels line 288 Force.com save problem
Do you know if the break can be added & saved in the custom label?
Thanks again for all your suggestions :)
Hi,
You can try from user interface Custom Labels,then you will not face this issue.
ok anyway
Now you can try like below syntax. it is working fine.
Hi HariDinesh.
Thank you for your help. Adding "This is </br> Test Label111 <br> second Line" works perfectly.
Much appreciated. it works like a charm!