Textarea ignores first line in case of blank line
-------------------------------------------------

                 Key: WICKET-2812
                 URL: https://issues.apache.org/jira/browse/WICKET-2812
             Project: Wicket
          Issue Type: Bug
          Components: wicket
    Affects Versions: 1.4.5
         Environment: IE6 / FF3.6 / Opera9
            Reporter: Rutger Jansen


When the content of a textarea starts with an empty line, this line disappears 
when it is placed in the html.
This is a known problem with the html textarea element.
<textarea>test</textarea> will result in the same as:
<textarea>
test</textarea>
Meaning that the first newline in the textarea is ignored. In case of opening a 
page with a textarea with a leading blank line, this line will be removed when 
the form is submitted again.

See for similar issues in the apache jira STR-1366 and BEEHIVE-1005

A possible solution is to change the following method in 
org.apache.wicket.markup.html.form.TextArea in something like:
  protected final void onComponentTagBody(final MarkupStream markupStream, 
final ComponentTag openTag) {
    checkComponentTag(openTag, "textarea");
    String value = getValue();
    if (value != null && value.startsWith("\n")) {
      value = "\n" + value;
    } else if (value != null && value.startsWith("\r\n")) {
      value = "\r\n" + value;
    } else if (value != null && value.startsWith("\r")) {
      value = "\r" + value;
    }
    replaceComponentTagBody(markupStream, openTag, value);
}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to