You need to sign in to do that
Don't have an account?
Middha
Adding a new line / linefeed in Visualforce
Hi,
I am creating a string in my APEX class which needs to have new line characters in it. For eg:
"This is line 1.
This is line 2."
I need to show this on my Visualforce page. It works but the new line char does not appear on the Visualforce page. I have tried adding almost all types of linefeed chars possible but none worked.
When i use "This is line 1 \n This is line 2", it shows the same in Visualforce page without converting it to a new line. I have tried \n,\r,\n\r,<br/>,<br/> and few others. I also tried setting escape attribute of "outputText" on visualforce but it didnt worked.
Is there any way to make it work.
Thanks
[GM]
I am creating a string in my APEX class which needs to have new line characters in it. For eg:
"This is line 1.
This is line 2."
I need to show this on my Visualforce page. It works but the new line char does not appear on the Visualforce page. I have tried adding almost all types of linefeed chars possible but none worked.
When i use "This is line 1 \n This is line 2", it shows the same in Visualforce page without converting it to a new line. I have tried \n,\r,\n\r,<br/>,<br/> and few others. I also tried setting escape attribute of "outputText" on visualforce but it didnt worked.
Is there any way to make it work.
Thanks
[GM]
Controller:
public String getStr() {
return 'Hello
New Line';
}
Page:
The docs for escape read:
A Boolean value that specifies whether sensitive HTML and XML characters should be escaped in the HTML output generated by this component. If you do not specify escape="false", the character escape sequence displays as written. Be aware that setting this value to "false" may be a security risk because it allows arbitrary content, including JavaScript, that could be used in a malicious manner.
Regards,
Jon
Message Edited by hokusai on 11-03-2008 08:42 PM
You can do this if your Visualforce looks like this:
and your controller like this:
Regards,
Jon
Message Edited by hokusai on 11-12-2008 06:49 AM
Why that's simple: If you want a line-break, simply concatenate the function br() into your text.
"This is Line 1"&br()&
"This is Line 2"
produces the value:
This is Line 1
This is Line 2
&br()& is not working