PDA

View Full Version : Strange behaviour with binding to Textarea



kantorn
Aug 26th, 2004, 08:59 AM
I have a problem regarding spring:bind and 'Textarea'

I the db (MySQL 4.0.x) the string looks fine, but when I load a textstring throught <spring:bind>-tag, the bind mechanism(??) suddenly inserts blank spaces or tabs before the string, which "puts" the text an annoying distance to the right in the textarea.


Anybody know why, and what can you do about it?

davison
Aug 26th, 2004, 09:13 AM
are you sure it's not the HTML at fault? Textarea content is treated literally, so if your code looks something like:


<textarea>
$&#123;status.value&#125;
</textarea>


then you will see this effect because of the line break and indentation in the source. It needs to be


<textarea>$&#123;status.value&#125;</textarea>

kantorn
Aug 27th, 2004, 02:18 AM
That was it.
You live, you learn.

Thank you for answering!

j2ux
Sep 8th, 2004, 07:18 AM
It maybe a workaround but there's still a bug.

The following code is taken from the petclinic sample and does NOT work with Spring 1.1 final (no line break included):

<TEXTAREA rows="10" cols="25" name="description" value="<c:out value="${status.value}"/>" ></TEXTAREA>

And IMO it shouldn't matter if there's a line break or not...

Thanks,
Lars

davison
Sep 8th, 2004, 09:31 AM
It maybe a workaround but there's still a bug

The 'bug' is in the petclinic code in that case. The textarea element should not have a value attribute (see http://www.w3.org/TR/html4/interact/forms.html#h-17.7). The value should be specified between the textarea tags.

I'll take a look at it and fix the samples. Thanks for pointing it out.

Regards,

j2ux
Sep 8th, 2004, 09:48 AM
OK, thanks for pointing that out !