Reputation: 31637
I am saving news from textarea in database and showing them again on a JSF page.
When I print the bean data I have it as below.
This is line 1
This is line 2
In textarea when I try to edit, I see same as above. But when I try to print in <h:outputText>
I see it as below.
This is line 1 This is line 2
Even when I print using Sytem.out.println()
, I see output as
This is line 1 This is line 2
Any idea how can I get this new line in <h:outputText>
?
I also tried this answer which suggests to use white-space: pre
.
This is working, but when the length of the text is long, all long line is coming in one line instead of next line and because of that I am getting horizontal scrollbar which is not what I want.
This answer works fine for small text but as news are large in length, this is problem.
Upvotes: 2
Views: 2293
Reputation: 1108722
If you want both preformatting and wrapping, use instead:
white-space: pre-wrap;
If you want to support IE6/7 as well (which doesn't support pre-wrap
), use instead:
white-space: pre;
word-wrap: break-word;
Upvotes: 7