I don't know why '\n' new line is not working

  • 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

  • Sergej Utko

    Sergej Utko Correct answer

    9 years ago

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

    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).

    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
    at visual force error message.

    It works as expected.

License under CC-BY-SA with attribution


Content dated before 7/24/2021 11:53 AM

Tags used