users@woodstock.java.net

Preserving line breaks between TextArea and StaticText

From: Aristides Papadopoulos <apapad.zzzzz_at_gmail.com>
Date: Fri, 8 Feb 2008 19:43:00 +0200

Hi all.

I am building a CRUD application where the user enters some text (that can
be quite long) in a TextArea, and then this text is saved to a database.
In the view page, the text is displayed in a StaticText component. The user
also has the option to edit this text in a popup window that contains a
TextArea initialized so that it contains the text.

What I want to do, is to preserve line breaks during this cycle. When the
text is saved in the database it carries with it the Java \n and \r escape
codes. When this text is reloaded in a TextArea, it is rendered with line
breaks (at least in Firefox, haven't tested it in IE), but in a StaticText,
this doesn't happen.

Any ideas about how I could do that?
I tried to replace \n 's with <br/>'s before saving the text to the
database, but when I load this text in a TextArea, the <br/>'s are printed
and there is no 'escape' attribute for TextAreas to turn it off.

Would using a converter be useful?

Thanks.