Line-breaks in Visualforce Page and Salesforce1


I have a filed contains long text in Salesforce.com. When I use “\n” to move some to next line, it just display an empty space.

If I use “<br>”, it works with outputText with escape=”false” but suffer from scripting-attacks according to VisualForce: convert carriage returns to html line-breaks in a long text field. This doesn’t work for Salesforce1 because “<br>” is displayed without line breaks.

Line breaks and consecutive spaces in outputText are removed on postback and Laurent Stanevich suggests to use outputField replacing outputText. It works in my case on both browser and Salesforce1.

Reference

  1. GooglePlay: Salesforce1
  2. Salesforce: apex:outputField
  3. Salesforce: apex:outputText
  4. Salesforce: Line breaks and consecutive spaces in outputText are removed on postback
  5. Salesforce Stack Exchange: I don’t know why ‘\n’ new line is not working
  6. StackOverflow: Difference between \n and \r?
  7. StackOverflow: VisualForce: convert carriage returns to html line-breaks in a long text field
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s