This probably isn't a struts problem if I am guessing correctly...

I assume that the problem is you enter text into the textarea and have several new lines eg

paragraph number 1 with some text that might wrap at the edge of the textarea
paragraph number 2 with some different text
paragraph number 3 to end the textarea


This gets stored in MySql, but when the text is redisplayed on the HTML page it appears like this:

paragraph number 1 with some text that might wrap at the edge of the textarea paragraph number 2 with some different text paragraph number 3 to end the textarea

eg missing the line breaks.

To fix this the developer needs to do a search and replace on the text looking for /n (the newline character) and replacing it with <br/> the html line break.

You only want to do this when displaying the text, not when you put it into the database. If you wanted to edit this text again it would have <br/> tags instead of newlines which would look bad. Also if you use something like <bean:write> to write out the text it will try to escape the characters, meaning the <br/> will change into &lt;br/&gt; and not work as line breaks.

I use this taglib http://jakarta.apache.org/taglibs/doc/string-doc/intro.html for doing the replace in the JSP page after the html has been escaped. I use it with JSTL eg

<str:replace replace="NL" with="<br>NL" newlineToken="NL"><c:out value="${content}" /></str:replace>

but you might be able to use it like this (if using struts tags):

<str:replace replace="NL" with="<br>NL" newlineToken="NL"><bean:write name="content" /></str:replace>


Catalin :: Braescu wrote:


I am not the developer but rather the internal client who asks a colleague
developer deliver some feature and the developer can't find the solution.

Anyway, we have a blog application written in Struts. The user inputs some
text, consisting of more than one paragraph. The submit is done using
textarea from Struts, not from HTML (I can't explain better, I am not the
developer, but I am sure you understand what I mean). Unfortunately at this
stage all formating of text (most important paragraph markings) is cleared
away; within Mysql the text is one single chunk.

There must be a solution to upload text corectly into a database using
Struts, so if there are any paragraphs they are preserved during submit. Any
hints?

With many thanks in advance for absolutely any help,


Catalin


--
Catalin Braescu
Scuba.ro
Bucharest - ROMANIA (Europe)




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]






--
Jason Lea




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to