Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My controller code is as follows -

       for(String resStr : responseArray){
            if(resStr.indexOf('r_error_str') != -1){
                responseString += resStr.substring(resStr.indexOf('=') + 1); 
                responseString += '\n';

but when i display this 'responseString ' String using 'apex:outputLabel or apex:outputText or as Exception message '\n' is not converting in new line. Whole String is coming in one line.

Can anyone explain why is this happining

share|improve this question
up vote 4 down vote accepted

just use <br/> in controller and escape="false" in visualforce text.

share|improve this answer
This does work of course, but if you're looking to publish on the AppExchange the use of escape="false" will be heavily frowned upon (from experience). – LaceySnr Dec 23 '12 at 0:26
It is not working if i set message in user define exception object as message and rending that at visual force page. It is showing <br/> at visual force error message. – Pramod Kumar Dec 23 '12 at 15:13

The simple answer is using '\n' will not work in HTML elements as it is just basically white space, google your problem and you'll get lots of results.

Could you possibly 'repeat' in your VF on the responseArray?

share|improve this answer
  currentAddress = currentStreet;
        currentAddress += '\r\n';
        currentAddress += currentCity + + ' ' + currentState  + ' ' + currentZIP ;
        currentAddress += '\r\n';
        currentAddress += currentCountry;

using the '\r\n' works with outputtext .Please try same

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.