1
votes

In my Liferay Spring MVC portlet new lines on Text Area do not work, while in a plain Spring MVC context they are working.

Plain Spring MVC

Text area tag is <form:textarea path="theTextArea"/>

User input contains three separate lines:

aaa
bbb
ccc

On submit when I inspect the bean at server side it contains aaa\r\nbbb\r\nccc and the same is saved in the database.

On my view page I am using <pre><c:out value="${theBean.theTextArea}"></c:out></pre> and I see three lines on page.

But the same is not working in the Liferay Spring MVC portlet. New line are converted to blank space:

aaa
bbb
ccc

is converted to aaa bbb ccc.

I don't know how to solve this problem in Liferay.

The liferay spring mvc jsp code

<form:textarea
    path="titleofEvent"
    id="titleofEvent"
    name="titleofEvent"
    class="input-large" rows="" cols="" maxlength="600" tabindex="1"/>
1
You give details on your working code, but not on your code that fails. How do you expect us to tell you what you'll have to change when all we know is that a "Liferay Spring MVC portlet" is involved? - Olaf Kock
Hi Olaf I am using same spring tag with some bootstrap css <form:textarea path="theTextArea" class="input-large"/> - Manu

1 Answers

0
votes

Liferay uses the StripFilter to compact white spaces in the response. Usually it tries to keep the content of <input> and <pre>. Unfortunately instead of looking for <textarea> it is looking for "textarea " (with a space at the end).

So if you add any attribute to your textarea, the content should keep all newlines in the tag.