1

I have custom label C_label with the value I am God. God is Great.

C_label = I am God.
    God is Great.

The second sentence is in a new line.

When I use this custom label to show message in exception, the message is displayed in a single line.

try
{
   divide by 0;  //exception here causes to enter catch block
}
   catch(exception e);
{
   throw exception(Label.C_label);
}

The message is displayed as I am God. God is Great. . The second will not be displayed in a new line. Is there any way to maintain the format ?

Workaround i used:

Split the string with any random character.

String s = 'I am God. 555 God is Great'.
List<String> l = s.split('555');
Apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,''+l[0]));
Apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,''+l[1]));

Display the message using <apex:pageMessages>;. The message will be displayed with bullets in a separate line.

2
  • 1
    Did you try to use pageMessages ? You have an attribut named "escape". If set to "false" you can add html tag in your custom label like <BR/> in order to display your message in two lines Commented Jan 20, 2015 at 14:17
  • user2294438, I've edited your post to remove the html tags and to format your code using the preformatted text button and inline escapes where I believed it appropriate. If I've misinterpreted your intent, please visit Help center to learn how to use the editor so your messages will display correctly.
    – crmprogdev
    Commented Jan 20, 2015 at 18:15

0

You must log in to answer this question.

Browse other questions tagged .