Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-2812

Textarea ignores first line in case of blank line

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.4.5
    • 1.5-M1
    • wicket
    • IE6 / FF3.6 / Opera9

    Description

      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);
      }

      Attachments

        1. TextArea.java.patch
          0.9 kB
          Dr. Erich W. Schreiner

        Activity

          People

            ivaynberg Igor Vaynberg
            rutgerpuntnet Rutger Jansen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: